在角JS绑定值输入 [英] Binding value to input in Angular JS
本文介绍了在角JS绑定值输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的输入
<输入类型=文本名称=widget.titleNG模型=widget.titleVALUE ={{widget.title}}/>
我要动态地改变输入值,所以我使用的,但它不会改变的值:
$ scope.widget.title ='A';
解决方案
您不需要设置价值可言。 NG-模型利用一切护理:
- 从模型中设置输入值
- 当你改变输入更新模型值
- 当您更改从JS模型更新的输入值
下面是这个小提琴: http://jsfiddle.net/terebentina/9mFpp/
I have input like this
<input type="text" name="widget.title" ng-model="widget.title" value="{{widget.title}}"/>
I want to change input value dynamically so i use that but it doesn't change the value:
$scope.widget.title = 'a';
解决方案
You don't need to set the value at all. ng-model takes care of it all:
- set the input value from the model
- update the model value when you change the input
- update the input value when you change the model from js
Here's the fiddle for this: http://jsfiddle.net/terebentina/9mFpp/
这篇关于在角JS绑定值输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文