【发布时间】:2013-02-26 22:19:57
【问题描述】:
我有一个设置了帐户的路由器,以及 account/:account_id 选项。当用户登陆我的应用程序的索引页面时,我会将它们转换到帐户路由。
Social.Router.map(function() {
this.resource('accounts', function(){
this.resource('account', { path: ':account_id'});
});
});
Social.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('accounts');
}
});
我想做的是根据某些条件将它们转换为指定的 :account_id 路由。目前我只想获取数组中的第一个帐户并使用它。但在未来,这可能是一种将他们转移到他们查看的最后一个帐户的方法。像这样的:
Social.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('accounts/:account_id');
}
});
文档给出了“详细信息”,但没有提供示例,仅提供以下内容:
transitionTo(名称、型号)
过渡到另一条路线。可选择为路线提供模型 有问题。该模型将使用 序列化钩子。
我尝试了以下方法:
this.transitionTo('accounts/4');
Uncaught Error: assertion failed: The route accounts/4 was not found
this.transitionTo('accounts', Social.Account.find(1));
Uncaught More objects were passed than dynamic segments
【问题讨论】:
标签: ember.js