Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS comparing with $$hashkey

Tags:

angularjs

I am trying to compare an object included within a repeater to an object just returned from the server.

Because the repeated object contains the hashkey property angular.equals evaluates to false.

I guess i could just delete the property but i don't know if their is an angular way to handle this.

thanks

like image 662
Marco Avatar asked Mar 31 '15 15:03

Marco


1 Answers

There is an angular way to handle this. You need to track by a unique field that each object has. For example instead of:

item in items

Do:

item in items track by item.id

Checkout angular's documentation regarding ngRepeat and $$hasKey

like image 85
Cumulo Nimbus Avatar answered Nov 06 '22 13:11

Cumulo Nimbus