DEV Community

Sanjay Patel
Sanjay Patel

Posted on

2 2

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay