【发布时间】:2015-07-10 13:38:48
【问题描述】:
在我的 Ember 应用程序中,我有两条路由,people 和 person。
当我转换为 person 时,当前模型的值被绑定到应用程序控制器中的一个属性。
App.ApplicationController = Ember.Controller.extend({
needs: [ 'person' ],
currentPerson: Ember.computed('controllers.person.currentPerson', function () {
var person = this.get('controllers.person.currentPerson');
return person ? 'selected person #' + person.id : 'no one has been selected';
})
});
App.PersonController = Ember.Controller.extend({
currentPerson: Ember.computed.alias('model')
});
当我从 person 路由转换出来时,我想清除该值,理想情况下销毁 person 模型。
我试过了:
willTransition: function () {
this.get('model').destroy();
}
但这不起作用。如何正确删除缓存的路由模型?
示例:http://emberjs.jsbin.com/xogati/1/edit?html,js,output
谢谢!
【问题讨论】:
标签: javascript ember.js