2

Using the new router and Angular 1.4, is it possible to define the default component for a particular viewport? For instance, my side and top navs are components and currently I have to define every route like this:

    $router.config([
        {
            path: '/',
            components: {
                'topbar': 'topbar',
                'sidebar': 'sidebar',
                'default': 'dashboard'
            }
        },
        {
            path: '/notice/new',
            components: {
                'topbar': 'topbar',
                'sidebar': 'sidebar',
                'default': 'notice.new'
            }
        }
    ]);

As you can see, I have to define the topbar and sidebar components in every route, even though they are exactly the same. Is there a way to tell the new router "Always use this component for this viewport, unless overriden by a particular route"?

4

0 回答 0