Create component to specific module with Angular-CLI

后端 未结 26 1976
既然无缘
既然无缘 2021-01-29 19:46

I\'m starting to use angular-cli and I\'ve already read a lot to find an answer about what I want to do...no success, so I came here.

Is there a way to create a componen

26条回答
  •  悲哀的现实
    2021-01-29 20:16

    1. First, you generate a module by executing.
    ng g m modules/media
    

    this will generate a module called media inside modules folder.

    1. Second, you generate a component added to this module
    ng g c modules/media/picPick --module=modules/media/media.module.ts
    

    the first part of the command ng g c modules/media/picPick will generate a component folder called picPick inside modules/media folder witch contain our new media module.

    the second part will make our new picPick component declared in media module by importing it in the module file and appending it to declarations array of this module.

提交回复
热议问题