question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enhance - ng generate route

See original GitHub issue

ng route update

The current mechanism to add routes does not provide the flexibility that is needed to generate routes

Current

ng route library yields:

|-- app
|   |-- library
|   |   |-- library-detail.component.html
|   |   |-- library-detail.component.css
|   |   |-- library-detail.component.spec.ts
|   |   |-- library-detail.component.ts
|   |   |-- library-list.component.html
|   |   |-- library-list.component.css
|   |   |-- library-list.component.spec.ts
|   |   |-- library-list.component.ts
|   |   |-- library-root.component.spec.ts
|   |   |-- library-root.component.ts
|   |   |-- library.service.spec.ts
|   |   |-- library.service.ts
|   |-- ...
|-- app.ts

Issues

  • Not all routes will want a root, list and detail components.
  • All routes are added to the root (no child routes)
  • Need to be more granular with what is generated (via params)

Concerns with new proposal

  • Simplicity - make it easy for devs to use
  • Style - adhere to a community accepted style guide

Proposed

Create a list of parameters to configure what is generated out of ng route <name>

Parameters

  • Parent [optional]
    • will specify where the new route will be placed
    • will allow adding of child routes without cd-ing to that route/directory
  • routes [optional]
    • list of child routes to be created

Parameters can be specified via command line i.e.

  • With children

    ng generate route library --routes book reference
    
  • Create base with one child then add another by specifying parent

    ng generate route library --routes book
    ng generate route book --parent library
    

When calling the command with no arguments the user can be prompted

ng generate route
> Name of the route to generate?
> Parent route? (hit enter for no parent)
> Child route?

If more than one instance of parent is found the user will be prompted to choose

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Broccocommented, Apr 8, 2016

@ravtakhar yes, I am currently working on the generation of routes

1reaction
Broccocommented, Apr 15, 2016

@oreon you are doing nothing wrong, the route template is currently under construction and in a state of flux. Until it is ready you can generate a component and register it as a route in the parent component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng generate - Angular
Generates and/or modifies files based on a schematic. ... Route path used to produce the application shell. ... ng generate application [ name...
Read more >
Angular CLI route - Stack Overflow
This is what worked for me. Use angular-cli to create the seed project; Generate new components using ng g component. Then manually add...
Read more >
How to Add Routing to an Existing Angular Project - Sam Julien
When we first create an Angular app with the Angular CLI using ng new , it gives us an option to add routing....
Read more >
Angular CLI generate routing module - YouTube
In this video we will discuss generating routing module using the Angular CLI.Healthy diet is very important both for the body and mind....
Read more >
how to add routing and components to an Angular 9 app using ...
In the Angular CLI the full command to create a new component is: “ng generate component <directory-name>\<your-component-name>. However, we can use a shorthand ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found