0
  1. for example if we create any component from angular-cli (ng g component compName ) it is automatically declaring

https://i.stack.imgur.com/KiXzj.jpg

  1. same way i want to declare automatically in routing at the time of component creation, like this

https://i.stack.imgur.com/RthNi.jpg

  • Not sure I understand the question correctly but it seems to me that you are looking for something like lazy loading ? https://angular.io/guide/lazy-loading-ngmodules – Leo Feb 04 '19 at 12:48
  • There is no such option or functionality https://github.com/angular/angular-cli/wiki/generate-component – Jota.Toledo Feb 04 '19 at 12:54

2 Answers2

1

As of I know, Angular cli generates a component on ng g c comp-name and add the component to the nearest angular module to make the component work.

Putting the component in the routes is at the sole discretion of the developer and hence angular cli will not put it in the routes. It has to be done manually by the developer

dileepkumar jami
  • 2,185
  • 12
  • 15
0

We cannot declare the routes automatically, its totally depends on the functionality. We need to add them manually.

Ankur Jain
  • 221
  • 1
  • 6