javascript - ng-repeat input keeping same value for each loop -


i have ng-repeat comment input inside loop. ng-model="comss.comment", when start type on first input, can see typing on 2nd , of other inputs. how can stop this? i've tried adding name unique id did not work.

here code:

<li class="item" style="margin-top:20px;" ng-repeat="schedule in discoverloaded | filter:schedulesearch | limitto:numberofitemstodisplay">    <input type="text" ng-model="comss.comment" required='required' placeholder="write comment..">    </li>

since you're in loop, accessing comss.comment each loop going same model, need modify template , model slightly:

<li class="item" style="margin-top:20px;"   ng-repeat="schedule in discoverloaded | filter:schedulesearch | limitto:numberofitemstodisplay track $index">    <input type="text" ng-model="comss[$index].comment"     required='required' placeholder="write comment..">  </li> 

in controller larger object, loop of 2 items in discoverloaded, have in comss:

comss = {   0: {     comment: ''   },   1: {     comment: ''   } }; 

in template can't access via comss.0.comment, why use comss[$index].comment you're inside loop when assign model.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -