2014-02-06 2 views
1

이 내 코드입니다 주소 :리디렉션

App.Router.map(function() { 

    .... 

    this.resource('profile', function() { 
     this.route('user'); 
     this.route('user.edit', { path: '/:user_id/edit' }); 
     this.route('password'); 
     this.route('company'); 
     this.route('company.edit', { path: '/:company_id/edit' }); 
     this.resource('products', function() { 
      this.route('index'); 
      this.route('show', { path: '/:product_id/show' }); 
     }); 
    }); 

    .... 

}); 

App.ProfileRoute = Ember.Route.extend({ 
    redirect: function() { 
     this.transitionTo('profile.user'); 
    } 
}); 

을 그리고 나는 link-to 있습니다 #/profile/products/index에 연결되어

{{#link-to "products.index" }}<i class="icon-barcode icon-2x pull-left icon-border"></i>{{/link-to}} 

합니다. 그러나 이는 ProfileRoute의 리디렉션을 트리거합니다. 이는 원하지 않습니다. #/profile 또는 #/profile/index에 액세스 할 때 만 리디렉션되어야합니다.

어떻게하면됩니까?

답변

1

App.ProfileRoute에서 App.ProfileIndexRoute으로 변경하십시오. 다음과 같은 :

App.ProfileIndexRoute = Ember.Route.extend({ 
    redirect: function() { 
     this.transitionTo('profile.user'); 
    } 
}); 

App.ProductsRoute 부모로 App.ProfileRoute 경로를, 그래서 (beforeModel a.k.a)을 redirect, 트리거, 당신은 당신의 바람직하지 않은 행동을 얻을 수있다. /profile

를 호출 할 때 App.ProfileIndexRoute가 단지 나는

도움이되기를 바랍니다 트리거되기 때문에, App.ProfileIndexRoute 수정을 사용하여