EmberJS redirect()很奇怪

时间:2015-09-02 14:10:39

标签: javascript ember.js ember-cli

我有路线:

this.route('deals', function () {
    this.route('order', {path: ":id"});
});

In"特卖"路线我这样做:

redirect(model, transition){
    if(transition.targetName != 'deals.order'){
      var order = model.orders.objectAt(0);

      return this.transitionTo('deals.order', order);
    }else{
      return this._super(model, transition);
    }
  },

如果我打开http://localhost:4200/deals/1,它可以正常工作,但如果那时我转到任何其他路线,然后使用菜单转到/deals,它的工作原理如下:

Preparing to transition from 'deals.order' to ' settings.index' //any other route
Transitioned into 'settings.index' //here everything is ok still and next I click menu to go to "deals" route.

Preparing to transition from 'settings.index' to ' deals.index'

接下来的过渡没有配对,我完全不知道为什么:

Transitioned into 'deals.order' (it goes with orders ID)
Preparing to transition from 'deals.order' to ' deals.index' //why???
Transitioned into 'deals.index' //why???

我甚至不知道如何调试它!

0 个答案:

没有答案