$$hashKey for object in angular2?

2019-09-19 04:43发布

问题:

I am new in angular2 and wondering if there is any alternative to $$hashKey in angular2.

I used $$hashKey in angularjs for identifying objects.

for ex.

var arrayItem = {};
for (var key in arrayInstance[0]) {
    if (arrayInstance[0].hasOwnProperty(key)) {
       console.log('Key ' + key);
       if (key != '$$hashKey') {
           arrayItem[key] = angular.copy(arrayInstance[0][key]);
       }
    }
}
arrayInstance.push(arrayItem);

so I want to alternative for this in angular2.

any inputs?

thanks

回答1:

Please read the deep dive about that subject Understanding "Object Identity" With ngFor Loops In Angular 2.