我有以下路由器:
Router.map(function() {
this.resource('cart', function() {
// order routes
this.route('shipping');
this.route('checkout');
this.route('payment');
this.route('thanks');
});
});
当我在感谢路线上时,我想在结账时取消设置自定义评论属性。这是因为下次客户访问结账路线时,会再次显示注释。
因此,为了表示感谢,我做了以下操作:this.set('controllers.cart.checkout.commentCustomer', "");
但我得到了这个错误:Uncaught Error: Property set failed: object in path "controllers.cart.checkout" could not be found or was destroyed.
这意味着什么?
你很幸运,因为自1.7.0以来,Ember在路由中拥有绝对出色的resetController挂钩。正是针对这种情况。
App.CartCheckoutRoute = Ember.Route.extend({
resetController: function(controller, isExiting, transition) {
controller.set('commentCustomer', '');
}
});