Google Polymer Repeat value in range 1...n -


i've started messing polymer , i've done basic tutorial social media cards. in several cards care looped on repeat="{{post in posts}}". repeat="{{post in range 1...10}}". i'd use published property cols provide max value instead of 10. i've been able working setting cols property [1,2,...,9] unreasonable large set of values. i've expanded on using ready function , executing this.colsar = new array(cols), in repeat `{{col in colsar}}.

what best/correct method of looping on variable number of elements number determined property?

to add lets cols property dynamically changed via select input. should cause re-draw when new value selected.

generally best way use computed property express filtered array.

something this:

 <template repeat="{{post in slice}}">    ...   computed: {     slice: 'sliced(posts)'   },   sliced: function(posts) {     return posts.slice(1, 3);   } 

however, right now, computed property engine doesn't automatically arrayobserve posts, have manually force re-compute when array structure changes.

  kick: 0,   computed: {     slice: 'sliced(posts, kick)'   },   sliced: function(posts) {     return posts.slice(1, 3);   },   postschanged: function() {     this.kick++;   } 

incrementing kick forces data engine recompute slice (gives kick). fwiw, trying improve particular situation, above technique should work in short term.

working example:

http://jsbin.com/dadeto/3/edit


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -