Want to push and pop arrays in Ember.js? For working with collections, Ember.js provides an Array wrapper class, Ember.Array / Ember.MutableArray
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// JS App.obj = Ember.Object.create({ "things": Ember.A(["1", "2"]) }); App.obj.things.pushObject("3"); // pushObject notifies observers // HTML + Handlebars {{#with App.obj}} <ul> {{#each things}} <li>{{this}}</li> {{/each}} </ul> {{/with}} |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.