DEV Community

Sanjay Patel
Sanjay Patel

Posted on

Dynamic imports for lazy routes from old towards new: Angular 8

Lazy-loaded routes now use the standard dynamic import syntax instead of a custom string. This means that TypeScript and linters will be better able to complain when modules are missing or misspelled.

So a lazy-loaded import that looked like this:

{ path: '/cart', loadChildren: './cart/cart.module#CartModule' }

Will now look like this:

{ path:/cart, loadChildren: () => import(./cart/cart.module).then(m => m.CartModule) }

The change in syntax will be taken care of for you if you’re using the ng upgrade command to upgrade your app.

Know more about updates on Angular 8 here

Top comments (1)

Collapse
 
matheusmurta profile image
Matheus Gonçalves Murta

thanks you save my day