1
http://jsbin.com/qoyudape/1/edit灰烬模板模型更新
后不更新尽管使用.pushObject()
模板没有更新。我注意到它会更新,如果改为this
我在模板中使用model
或content
;
什么是this
在视图中指的是如果不是模型?是否有可能使用this
而不是model
或content
?
var App = Ember.Application.create();
App.ApplicationRoute = Ember.Route.extend({
model: function(){
return Ember.A();
}
});
App.ApplicationController = Ember.ArrayController.extend({
actions: {
update: function(){
this.get("model").pushObject(Ember.Object.create({a:"b"}));
console.log(this.get("model"));
}
}
});
模板:
<script type="text/x-handlebars">
<button {{action "update"}}>update</button>
<br><br>
{{#if this}}
array not empty
{{else}}
array empty
{{/if}}
</script>
但为什么它的工作在初始加载,但更新不工作? – Tomas
我不确定它是否在技术上有效,我认为它可能会在集合上观察其他内容并发现它是虚假的。 – Kingpin2k