Polymer 1.0 'array-style' path accessors, alternative to bracket notation in expressions

后端 未结 2 1599
既然无缘
既然无缘 2021-01-15 06:46

The Polymer 1.0 documentation states:

The path syntax doesn’t support array-style accessors (such as users[0].name). However, you can include indexe

2条回答
  •  情歌与酒
    2021-01-15 07:24

    You can make a computed binding. https://www.polymer-project.org/1.0/docs/migration.html#computed-bindings

    
    
    

    As an aside, you also need to update your repeat to dom-repeat https://www.polymer-project.org/1.0/docs/devguide/templates.html#dom-repeat

    Edit: Here is my ugly solution to the 2-way binding. The idea is that you have a calculated variable get the initial value and then update this variable upon updates with an observer.

    
    
    
    

    Edit 2: Updated the code in Edit 1 to reflect the obeserver changes pointed out by Vartan Simonian

提交回复
热议问题