Ember 中的嵌套路由
Nested routes in Ember
我希望我的设置区域看起来像这样:
..
/settings/:accountId/users
/settings/:accountId/users/:userId
我的路由器定义如下:
Router.map(function() {
this.route('login');
this.resource('settings', { path: 'settings/:settings_id' }, function() {
this.route('overview');
this.route('users');
});
});
这适用于显示用户列表页面。我不确定如何将它带到下一步并同时拥有 /users
和 /users/1
.
的路线和资源
谢谢。
在 Ember 的最新版本中,路由可以有子路由(为了命名空间)。
Router.map(function() {
this.route('login');
this.resource('settings', { path: 'settings/:settings_id' }, function() {
this.route('overview');
this.route('users', function(){
this.route('user', {path:':user_id'});
});
});
});
http://emberjs.jsbin.com/cutayuniga/1/edit?html,js,output
如果您使用的是旧版本,则必须将用户设为资源。
Router.map(function() {
this.route('login');
this.resource('settings', { path: 'settings/:settings_id' }, function() {
this.route('overview');
this.resource('users', function(){
this.route('user', {path:':user_id'});
});
});
});
我希望我的设置区域看起来像这样:
..
/settings/:accountId/users
/settings/:accountId/users/:userId
我的路由器定义如下:
Router.map(function() {
this.route('login');
this.resource('settings', { path: 'settings/:settings_id' }, function() {
this.route('overview');
this.route('users');
});
});
这适用于显示用户列表页面。我不确定如何将它带到下一步并同时拥有 /users
和 /users/1
.
谢谢。
在 Ember 的最新版本中,路由可以有子路由(为了命名空间)。
Router.map(function() {
this.route('login');
this.resource('settings', { path: 'settings/:settings_id' }, function() {
this.route('overview');
this.route('users', function(){
this.route('user', {path:':user_id'});
});
});
});
http://emberjs.jsbin.com/cutayuniga/1/edit?html,js,output
如果您使用的是旧版本,则必须将用户设为资源。
Router.map(function() {
this.route('login');
this.resource('settings', { path: 'settings/:settings_id' }, function() {
this.route('overview');
this.resource('users', function(){
this.route('user', {path:':user_id'});
});
});
});