Skip to content

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

Closed

Description

@probert94

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.

Activity

  1. probert94 commented on May 5, 2017

    @probert94
    ContributorAuthor

    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.

  2. angelozerr commented on May 5, 2017

    @angelozerr
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions