2
votes

So far I have not found a working demo with lazy loading in a named router outlet e.x. <router-outlet name="view"></router-outlet>. I have made a plunkr to find a way to make it work without success. Any help would be much appreciated.

https://plnkr.co/edit/EW3PZUMC63euf2QYxtW5?p=preview

In the example above View1, View2 and View3 are lazy loaded in the default router-outlet. View3_1 and View3_2 are lazy loaded in the named router-outlet without success.

2
Updated your plunkr to plnkr.co/edit/bhPyG3?p=preview since it had some error.ShivangiBilora

2 Answers

0
votes

I had tried to do it, but got :

Promise rejection: Invalid configuration of route 'yourRouteName': a componentless route cannot have a named outlet set

When we use named router-outlet it need component, not a module. I think it's impossible =( But i so need it.

0
votes

There is a proxy component workaround: We have this

 {
        path: 'me',
        outlet: 'hub',
        component: ProxyRouteComponent,
        children: [
            {
                path: '',
                loadChildren: 'hub#HubModule',
            },
        ],
    },

Where proxy route component is simply

import { Component } from '@angular/core';

@Component({
    selector: 'b-proxy-route',
    template: '<router-outlet></router-outlet>',
})
export class ProxyRouteComponent {
}