Rangle.io : Angular 2 Training

Updated a year ago

Abelardo (@abelardo) started discussion #250

4 months ago Β· 1 comment


Accessing to your shared LazyModule from another application


I have followed your tutorial about how to generate a shared module. All is fine. πŸ˜ƒ

But I would like to continue by generating a bundle to be imported from another application (called MAIN).

I am using these steps: https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e to generate it. These steps are right since I could export any app by following them.

But when I want to use a LazyComponent with a router created inside the MAIN application, I don't know how to do it:
{ path: 'myroute', loadChildren: 'app/lazy/lazy.module#LazyModule', data: { page: 'lavadero'}},

I would like to write: 'http://localhost:4200/myroute' in order to load the LazyModule but I don't know what the right 'path/to/LazyModule' should be.

Any help would be welcome. Nice handbook! πŸ˜‰

Kindest regards.


Abelardo @abelardo commented 4 months ago

There was a mispelling. This is the correction: { path: 'myroute', loadChildren: 'app/lazy/lazy.module#LazyModule', data: { page: 'myroute'}},

Abelardo @abelardo commented 4 months ago

I tried to load the EagerComponent:
{ path: 'myroute', component: EagerComponent', data: { page: 'myroute'}},
but it produces the same ouput:

ERROR in ./src/app/app.routing.ts

Module not found: Error: Can't resolve 'lazy-eager/src/app/eager.component' in '...\src\app'

resolve 'lazy-eager/src/app/eager.component' in '\src\app'

Parsed request is a module

using description file: \package.json (relative path: ./src/app)

Field 'browser' doesn't contain a valid alias configuration


What's wrong?

to join this conversation on GitBook. Already have an account? Sign in to comment

You’re not receiving notifications from this thread.

1 participant