angular.js - Ask about the problem that ng-bind cannot be bound in ng-repeat
習慣沉默
習慣沉默 2017-05-15 17:12:08
0
3
824

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

習慣沉默
習慣沉默

reply all(3)
某草草

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 ​​

Peter_Zhu

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.

淡淡烟草味

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template