cannot changed the property of an object inside an array

陌路散爱 提交于 2019-12-25 08:01:41

问题


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

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