Ale*_*lls 23 angular-cli angular5 ng-generate
我有以下目录结构
我想创建一个新页面,比方说,一个关于页面.我想把它放在src/app/page/about/*
所以我尝试:
ng generate component pages/about
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
Error: More than one module matches. Use skip-import option to skip importing the component into the closest module.
More than one module matches. Use skip-import option to skip importing the component into the closest module.
Run Code Online (Sandbox Code Playgroud)
使用页面存储我的单独页面是一个好主意吗?如何使用angular-cli在子目录中生成组件?
Bro*_*cco 35
因为有2个模块(app.module.ts,shared.module.ts)发现CLI不知道哪个模块中声明你的组件.为了解决这个问题,你必须告诉你CLI希望与申报的分量模块module选项
ng generate component pages/about --module=app.module
// or
ng generate component pages/about --module=shared.module
Run Code Online (Sandbox Code Playgroud)
要创建组件作为任何新模块的一部分,您还可以执行以下操作:
cd newModule to change directory into the newModule folder
ng g c newComponent to create a component as a child of the module.
Run Code Online (Sandbox Code Playgroud)
这对我有用。我收到与您收到的错误相同的错误。
| 归档时间: |
|
| 查看次数: |
25741 次 |
| 最近记录: |