<dom-module id=“my-list">
<template>
<iron-list items="{{myItems}}" as="item" indexAs="myIndex">
<template>
<div class="item">{{item.name}}</div>
</template>
</iron-list>
</template>
<script>
Polymer({
is:’my-list',
properties: {
myItems: {
type: Array,
notify: true
}
},
addItem: function(item) {
this.push("myItems", JSON.parse('{"name":"'+item+'"}'));
},
ready: function() {
this.myItems=[
{'name':'Taco'},
{'name':'Burger'},
{'name':'Fries'},
{'name':'Chips'}
];
}
});
</script>
</dom-module>Everything works, but from the ready() method I get "Uncaught RangeError: Invalid array length". This seems to happen whenever the array is set for the first time. While this does not impact operations from a browser, Cordova stops on this error.
Any ideas as to how to suppress or prevent this error? Kind of running blind as I can't find any example code to work off of.
<link rel="import" href="/elements/my-list.html"/><my-list></my-list>addItem: function(item) {
if(this.myItems==null) this. myItems =[];
this.push("myItems", JSON.parse('{"name":"'+item+'"}'));
console.log('my-list:'+item);
}