[英]Ember.js | dynamically add option to an Ember.select
I have an Ember select
: 我有一个Ember
select
:
{{ view Ember.Select valueBinding="category" contentBinding="categoriesList" }}
When I set the categoriesList in the controller in the init function, it works. 当我在init函数中设置控制器中的categoriesList时,它可以工作。
this.categoriesList = ['cat1', 'cat2'];
This populate my select as intended. 这会按预期填充我的选择。 But when I change this array after an ajax request, it stops working.
但是当我在ajax请求之后更改此数组时,它会停止工作。 What am I doing wrong?
我究竟做错了什么?
For bindings to work you should use ember.js built-in array methods like pushObject
, pushObjects
or removeObject
etc. 要使绑定工作,您应该使用ember.js 内置数组方法,如
pushObject
, pushObjects
或removeObject
等。
So to make things work try this: 为了使事情有效,试试这个:
this.categoriesList.pushObjects(['cat1', 'cat2']);
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.