Please tell me: I ng-repeat some items, and then each item will have a comment form. I use ng-bind="item.comment", but when submitting, I cannot see the comments in item.comment. The content is empty and seems not to be bound. How should I write this binding? I am using version 1.2.19. Thank you
某草草2017-05-15 17:14:08
Just start doing it. Whether it is vue or angular, model does two-way binding and bind does one-way binding. Usually forms use two-way binding to monitor values
天蓬老师2017-05-15 17:14:08
Thanks for the invitation
Please use ng-model, ng-bind is one-way binding. ng-model is a two-way binding.
If you still have questions about using ng-model, you can continue to discuss.
淡淡烟草味2017-05-15 17:14:08
Thanks for the invitation
<p ng-repeat="item in items">
<p>{{item.id}}</p>
<p>{{item.name}}</p>
<textarea ng-model="item.comment"></textarea>
<button ng-click="insertComment($index)">提交</button>
</p>
$scope.items=[
{id:1,
name:'a',
comment:''
},
{id:2,
name:'b',
comment:''
]
For form controls and data input, ng-model is used to bind data, and ng-bind and {{}} have the same function