Replace parent view from child route

只谈情不闲聊 提交于 2019-12-22 07:05:04

问题


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.

My routes are defined as:

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' });
        });
    });
});

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.


回答1:


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

Example: http://emberjs.jsbin.com/jacebeyira/1/edit?html,js,output



来源:https://stackoverflow.com/questions/27738130/replace-parent-view-from-child-route

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!