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

twitter logo ・1 min read

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

twitter logo DISCUSS
Classic DEV Post from May 4

The secret that the fonts industry doesn't want you to know

Finally the story of CSS's most unsung hero

Sanjay Patel profile image
I am a full-stack software engineer, having 8+ years of experience of software, web and mobile application development, deployment and maintenance. Founder @teclogiq
Join dev.to

Be a better developer. Free forever.