Friday, 15 January 2010

javascript - Angular.js: two-way binding inside ng-repeat -



javascript - Angular.js: two-way binding inside ng-repeat -

i'm working on angular application.

i want generate form arbitrary number of text input fields two-way bindings every individual input field. no buttons, no watchers. ng-model not working correctly because of scoping (if i'm not mistaken). input fields generated array ng-repeat this:

<div ng-repeat="item in items"> <label>{{item.name}}</label> <input type="text" placeholder="{{item.default}}" ng-model="{{item.value}}"> <!-- input should bound --> </div>

i want simple binding update items array in controller on changes in input.

any help appreciated.

just alter input tag reads:

<input type="text" placeholder="{{item.default}}" ng-model="item.value">

notice ng-model without curly braces.

working plunk: http://plnkr.co/edit/cldem9yiw2sk1u52iajl?p=preview

javascript angularjs

No comments:

Post a Comment