jeudi 29 janvier 2015

Is there a clever way to listen to specific properties in an array-model in Angular.js?


Vote count:

0




Let's say I have a model that looks like this:



[
{
label: "Hobbit 1",
isbn: 10
},
{
label: "Hobbit 2",
isbn: 20
},
{
label: "Hobbit 3",
isbn: 30
},

]


Is there a clever way, in Angular, to listen for any label changes and if so, get the isbn in an easy way?


The only way I know is to put up a $scope.$watch( model, function( new, old ) { ... on the whole model and then compare, by looping through all the items and comparing the label property against the previous version of the model. But there has to be a more clever way?



asked 1 min ago

corgrath

1,918






Is there a clever way to listen to specific properties in an array-model in Angular.js?

Aucun commentaire:

Enregistrer un commentaire