Joe Riggs
Joe Riggs

Reputation: 1324

ng-repeat inputs losing function losing focus

http://plnkr.co/edit/g89wEeG30sOXhgzHWX0Z?p=preview

I've been reading about this and the consensus seems to be that this issue when binding to primitives was resolved in 1.1.2*, yet my problem persists. Maybe I'm using the repeater incorrectly? Please note that I am unable to change the data-structure.

I'm open to any work-arounds or creative hacks. So far, the only thing I've been able get working correctly was using this version of angular: http://ci.angularjs.org/job/angular.js-pete/12/artifact/build/angular.js

But I dont think it's going to be patched in any time soon. Thoughts?

* Difficulty with ng-model, ng-repeat, and inputs

Upvotes: 6

Views: 2822

Answers (1)

pkozlowski.opensource
pkozlowski.opensource

Reputation: 117370

You need to use the new ngRepeat syntax (introduced in 1.1.x) and use track by $index:

<td ng-repeat="point in series.data  track by $index">
  <input type="number"  ng-model="series.data[$index]" />
</td>

Working plunk: http://plnkr.co/edit/CEwr2GJ4YrS5H7yBOKJn?p=preview

More info here

Upvotes: 14

Related Questions