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

Support for selecting Module when generating Component/Directive etc. #34

Closed
probert94 opened this issue Jan 26, 2017 · 2 comments
Closed

Comments

@probert94
Copy link
Contributor

Since Angular-CLI beta 25, the "generate" command lets you specify a module (see angular/angular-cli#3811)
The generate Wizards could support this to (using a Combobox with available modules?).
The nearest module could be selected by default.

@probert94
Copy link
Contributor Author

I just tested how this works and it seems like you must specify the path to the module file.
For example:
ng generate directive test --module ../app.module.ts

This allowes you to create a file in any directory and instead of declaring it in the nearest module, you can declare it in any module.

I have tested following cases:

  • Specify a non-existing file -> Command fails, no files generated/changed
  • Specify a file without @NgModule annotation -> Files are generated, but not added to any module
  • Specify a file with more then one @NgModule annotation -> Files generated and declaration added to last @NgModule in specified file

@angelozerr I guess this feature won't be needed verry often, as you usually want declarations to go into the nearest @NgModule.
But if we want to support this, a basic support with a file-chooser could be implemented pretty fast and would be enough for now.
Later we could extend it to show only files, which contain at least 1 @NgModule-annotation.

@angelozerr
Copy link
Owner

To be honnest with you, I don't know @NgModule, so I trust you! Any PR are welcome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants