I have a view that has this:
我有一个观点
<div ng-repeat="object in objects">
<input value="{{object.name}}" ngModel="object.name" ng-keyup="change(object)">
</div>
That fires this:
这火灾:
change: function(object) {
console.log(object);
}
The above works, and it outputs the object to the console, but when I edit the name from the input above, it continues to update the original object and not the one with the newly edited name. How do I go about linking the input in the view to the object being modified so when change() is called, it logs the object with the updated name?
上面的工作,并将对象输出到控制台,但是当我从上面的输入编辑名称时,它会继续更新原始的对象,而不是新编辑的名称。如何将视图中的输入链接到正在修改的对象,以便在调用change()时,它用更新的名称记录对象?
1 个解决方案
#1
2
Credit to Chris and PSL in the comments:
在评论中赞扬Chris和PSL:
I needed to change ngModel
to ng-model
我需要将ngModel改为ng模型。
#1
2
Credit to Chris and PSL in the comments:
在评论中赞扬Chris和PSL:
I needed to change ngModel
to ng-model
我需要将ngModel改为ng模型。