Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arrow function Vs String path in LoadChildren Route in Angular

In the following code, beside the fact that in the first example, we need to import productsModule to the file, What is the difference between these two ways of loading a route lazily?

{ path: 'products', loadchildren: () => productsModule }

vs

{ path: 'products', loadchildren: 'app/products/products.module#ProductsModule' }
like image 323
dash Avatar asked Feb 06 '26 09:02

dash


1 Answers

{ path: 'products', loadchildren: 'app/products/products.module#ProductsModule' }

Its a deprecated way for lazy loaded modules for Angular 8.

loadChildren route configs should be changed from a string such as

{ path: 'products', loadchildren: () => productsModule }

https://angular.io/guide/deprecations#loadchildren-string-syntax

like image 139
Maksym Petrenko Avatar answered Feb 09 '26 09:02

Maksym Petrenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!