angular.js - update `ng-model` with text.value
angular.js - update `ng-model` with text.value
我有一个javascript
事件要动态更新input value
var posx = event.target.querySelector('input.posx');
posx.value = event.dx;
它用于更新html
:
<input type="text" ng-model="posx" size="30" placeholder="x" class="post">
但不知何故它没有更新ng-model="post
.当我console.log($scope.posx);
时,我得到
定义
这里似乎有什么问题
这段代码可以在 Javascript 上下文中执行,
var e = document.getElementsByClassName('posx')[0];
var scope = angular.element(e).scope();
scope.posx = "updated value";
scope.$digest();
或
var e = document.getElementsByClassName('posx')[0];
angular.element(e).triggerHandler('input');
$scope.posx = event.target.querySelector('input.posx');
$scope.posx.value = event.dx;
尝试使用$scope
相关文章:
- Fighting with FRP
- 如何将输入(type=text)从html表单传递到javascript函数
- issue with FB.Event.subscribe
- geolocation-marker.js conflict with markerclusterer.js
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- WebComponentsJS with IE10
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- 指令的模板必须只有一个根元素:With restrict E&替换true
- 在文本区域中使用jQuery.text()保持换行符
- 用Javascript添加带有#text的tr元素
- 当用户按下回车键时,自动在text区域/text中插入消息
- 修正案'text'的元素
- Animating text along an circular path with svg & javascr
- 获取选定的li文本和设置菜单'it’s text with it
- angular.js - update `ng-model` with text.value
- Changing h- text with jQuery
- Jquery .text() with php foreach
- 这个Javascript做什么`new Function(“_”,“at”,“with(_){return(“+text
- internet explorer - Javascript select text with create range