简体   繁体   中英

Ember.js | dynamically add option to an Ember.select

I have an Ember select :

{{ view Ember.Select valueBinding="category" contentBinding="categoriesList" }}

When I set the categoriesList in the controller in the init function, it works.

this.categoriesList = ['cat1', 'cat2'];

This populate my select as intended. But when I change this array after an ajax request, it stops working. What am I doing wrong?

For bindings to work you should use ember.js built-in array methods like pushObject , pushObjects or removeObject etc.

So to make things work try this:

this.categoriesList.pushObjects(['cat1', 'cat2']);

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM