问题
There is a parent element. One of its property is an array of objects. This array is initialised in the ready function. The display of this array is handed down to a child element. What I want to do is to update the quantity of each element in the array whenever the multiplier property changed. I tried to use the override dirty checking technique described in the docs but couldn't get it to work. I would appreciate some guidance. [plunker link][1]
[1]: http://plnkr.co/edit/pCZyUC7YtgUU8cpejNpj?p=info
回答1:
Here is working example: Plunk
Few things are corrected, one is this:
//DO not use 'this.setItems.0.quantity.value', but:
this.set('setItems.0.quantity.value', newQuantity);
console.log("New arr val: ");
console.log(this.setItems[0].quantity.value);
Docs:
https://www.polymer-project.org/1.0/docs/devguide/model-data
https://www.polymer-project.org/1.0/docs/devguide/data-binding#array-binding
来源:https://stackoverflow.com/questions/40060221/cannot-changed-the-property-of-an-object-inside-an-array