How to save Firebase objects $asArray() with angularFire, when the objects contain ng-repetate

别等时光非礼了梦想. 提交于 2019-12-03 08:36:49
Ravbaker

Of course the best way to solve it in firebase like @Kato mentioned and have the real time binding to data from array into view you should use an extra firebase synchronized object through the $asArray instance.

Like in this solution: http://jsfiddle.net/RaVbaker/sb00kor8/1/ But you will loose then possibility to save data "on demand" with button like Save to Firebase. They will be saved instantly after change in firebase array object occurs. But it will also give you flexibility and synchronization of data across pages.

But other and much easier in your case is to change the way angular tracks uniqueness of objects in ng-repeat directive. It can be done by setting track by $index in the end of ng-repeat statement.

Changing ng-repeat="duration in account.durations" into this:

 ng-repeat="duration in account.durations track by $index"

Your jsfiddle updated with this solution: http://jsfiddle.net/RaVbaker/sb00kor8/2/

More info about track by for ngRepeat you can find obviously in official documentation.

Hope I helped.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!