Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to generate routes #64

Closed
dpurp opened this issue Nov 18, 2015 · 8 comments
Closed

Add the ability to generate routes #64

dpurp opened this issue Nov 18, 2015 · 8 comments
Assignees
Labels
feature Issue that requests a new feature help wanted

Comments

@dpurp
Copy link

dpurp commented Nov 18, 2015

Consider generating the initial app integrated with component router.

Add the ability to generate new routes, with something like:

ng generate route 'heroes/:id'  hero-details-component
@vikeen
Copy link

vikeen commented Nov 18, 2015

How do you see the routes getting created? Where would they live?

I think if there was just one route file this would be fairly easy, but if you go from a component or feature approach the route would maybe live in the related sub folder. The latter would make a route generator hard.

I do agree that the starting should have some route examples though.

@dpurp
Copy link
Author

dpurp commented Nov 18, 2015

hmm.. I was expecting a single, top-level routes file.

I can see how projects may want to register their routes in a sub-folder, but it seems like that would be more of an advanced user case. For the casual user wanting to start a new Angular2 project, it would be nice if routing worked "right-out-of-the-box."

@IgorMinar
Copy link
Contributor

My current thinking is that routes should really be routable components. These unlike regular components get generated in as a nested directory structure that maps to the route directory structure.

@cironunes cironunes mentioned this issue Nov 27, 2015
@cironunes cironunes added feature Issue that requests a new feature help wanted labels Nov 27, 2015
@filipesilva
Copy link
Contributor

I can pick this up soon.

@samjulien
Copy link

@filipesilva I am happy to help out with this too. I'm still learning ng2 but this project is great - the ember-cli is super useful.

@filipesilva
Copy link
Contributor

@samjulien thanks! I think it's going to be easy enough, but adding routes will need these two PRs in as well #66 #100

@IgorMinar Routable components seems the way to go, like described here in angular.io. Maybe even doing the routable component + list component + detail component + service all at once.

Thus, running

ng generate route heroes

Would generate the following folder structure

...
|-- app
|   |-- ...
|-- heroes
|   |-- heroes.component.ts
|   |-- heroes-detail.component.ts
|   |-- heroes-list.component.ts
|   |-- heroes.service.ts
|-- app.ts
...

And would add the child route definition to the router in app.ts:

...
  {
    path: '/heroes/...',
    name: 'Heroes',
    component: HeroesComponent
  },
...

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jan 9, 2016
@filipesilva
Copy link
Contributor

I've a PR proposal for route generation in #139. It does somewhat more than adding a single route.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Issue that requests a new feature help wanted
Projects
None yet
Development

No branches or pull requests

6 participants