Ember.js: transitionTo route, then to dynamic segment

前端 未结 5 1279
北荒
北荒 2021-02-01 07:45

I have a Router set up with accounts, and account/:account_id options. When the user lands on the index page of my app I transition them to the accounts route.

S         


        
5条回答
  •  故里飘歌
    2021-02-01 08:18

    You are not specifying the route path properly and you should have a route under the resource, not another resource. It should be like this:

    Social.Router.map(function() {
        this.resource('accounts', function(){
            this.route('account', { path: '/:account_id'});
        });
    });
    
    Social.IndexRoute = Ember.Route.extend({
        redirect: function() {
            this.transitionTo('accounts.account', Social.Account.find(1));
        }
    });
    

提交回复
热议问题