Skip to content

Create a route module when generating a module #3243

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

Closed
mhmo91 opened this issue Nov 23, 2016 · 12 comments
Closed

Create a route module when generating a module #3243

mhmo91 opened this issue Nov 23, 2016 · 12 comments

Comments

@mhmo91
Copy link

mhmo91 commented Nov 23, 2016

#Routing_module
According to angular documentation, it's considered the best practice to add routing module for each module, so my suggestion is, when generating a module, i think it makes sense to create a route module for it.
#update
Because it's not usually the case, may be another command like
ng g module routing x instead of ng g module x
Namaste

@delasteve
Copy link
Contributor

Have you tried the --routing flag when generating a module? This will generate you a some.module.ts and some-routing.module.ts file.

ng generate module SomeModule --routing (or ng g m SomeModule --routing, for short)

@mhmo91
Copy link
Author

mhmo91 commented Dec 1, 2016

I didn't know about that command!
thanksss

@mhmo91 mhmo91 closed this as completed Dec 1, 2016
@mhmo91
Copy link
Author

mhmo91 commented Dec 5, 2016

@delasteve Can u update the readme with this feature for others?

@delasteve
Copy link
Contributor

https://github.com/angular/angular-cli/wiki/module

Additionally, @Brocco has a PR out there to move the docs to the repo #3382

@josephdgb96
Copy link

And if I need the html , scss annd the component of this ?

@waleedshkt
Copy link

waleedshkt commented Jan 30, 2018

Hi @delasteve, I tried using your method for generating routing module. But it seems like it doesn't do the trick. I have another just-module.ts file in my directory. When I try to generate routing module, the latest versioned angular-cli I am using throws me an error of already-existing-module inside the directory.

@atom-morgan
Copy link

@waleedshkt If the module already exists, the CLI will throw errors. Just delete that file and then run the command again with the --routing flag.

@atom-morgan
Copy link

@josephdgb1996 You just generate a component with the same name as your module. Using the example @delasteve gave you'd just run ng generate component SomeModule.

@wagnergrilo85
Copy link

ng g m moduleName --routing

@nikhilbhalwankar
Copy link

nikhilbhalwankar commented Feb 11, 2019

Have you tried the --routing flag when generating a module? This will generate you a some.module.ts and some-routing.module.ts file.

ng generate module SomeModule --routing (or ng g m SomeModule --routing, for short)

Thanks. Did not know such command exists. This works perfect !

@mtoloto
Copy link

mtoloto commented Apr 18, 2019

@josephdgb1996 module does not have html or scss.
module has components wich has the html and stylesheets like css, scss, etc...

@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants