Array Values Are Not Getting Reflected While Rebinding In Emberjs
I have an array (['Name1','Name2','Name3']) which I am populating at page Load. Now at button click, I want to assign some other values to that array and populate the same like App
Solution 1:
Use Ember.set
method for changes to reflect it in template. so just replace App.myArray = ['Name4', 'Name5', 'Name6']
with the below
Ember.set(App,'myArray',['Name4', 'Name5', 'Name6']);
I would say dont use global variable for this kind of stuff. you can introduce it in IndexRoute itself.(i guess you are doing it for testing purpose).
Solution 2:
App
is an Ember object and myArray
is its one of the property we can not set value of Ember object's property directly using assignment
operator.
we have to use setter
functions.
you can use Ember.set
1.Ember.set(App,'myArray',['Name4', 'Name5', 'Name6']);
alternatively you can also use set
method provided by App
object to set its property.
App.set('myArray',['Name4', 'Name5', 'Name6']);
Post a Comment for "Array Values Are Not Getting Reflected While Rebinding In Emberjs"