从子路由替换父视图 [英] Replace parent view from child route
问题描述
关注我的问题 Ember中的嵌套路由我想替换从 / settings / users /
与 / settings / users / 1
呈现的视图。
Following my question here Nested routes in Ember I would like to replace the view rendered from /settings/users/
with the view rendered by /settings/users/1
.
我的路线定义为:
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' });
});
});
});
我的 user.hbs
模板将呈现 users.hbs
包含 {{outlet}}
。我想要 user.hbs
呈现代替 users.hbs
不在其中。
My user.hbs
template will render when users.hbs
contains {{outlet}}
. I want the user.hbs
to render in place of users.hbs
not within it.
推荐答案
将您的用户
模板更改为只有一个插座
Change your users
template to just an outlet
{{outlet}}
您的用户模板中的内容到您的用户/索引
模板中,那么只会在用户
路线,当你走得更远时,它不会显示索引路线。
And put the stuff from your users template into your users/index
template, then it will only show up when you're on the users
route, and when you go any deeper, it won't show the index route.
Cool stuff in the users index template
示例:http://emberjs.jsbin.com/jacebeyira/1/edit?html,js,output
这篇关于从子路由替换父视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!