Search code examples
angular-routingangular7

Is there a way to generate a router module that will automatically be imported in app-module.ts in angular?


I want to use the new router module for my angular 6 project, So I wondering if is there a way to generate angular 7's new router module that will automatically be imported in app-module.ts?


Solution

  • No. In angular 4+ platforms 'ng new' supports adding routing interactively. Implementing Routing in ng7 is same as in ng6. You can manually add a module using ng g module <moduele-name>. Later, import RouterModule from @angular/router.

    That being said, I don't see a reason why you want to use Routing from ng7 when your project is on ng6. Both support lazyloading for children. IMO, migrating the entire project to one version makes more sense.

    https://www.techiediaries.com/angular-routing-lazy-loading-loadchildren/