ng:ui开关不是angular5中的已知元素?
我试图使用ui开关,如下所示,但我发现一个错误:ng:ui开关不是angular5中的已知元素?,angular,angular5,uiswitch,Angular,Angular5,Uiswitch,我试图使用ui开关,如下所示,但我发现一个错误: ng : ui-switch is not a known element ng : if ui-switch is An angular component then verify it's a part of this module 要安装ui switch,我在Angular CLI中使用了以下命令: npm install ngx-ui-switch@^1.6.0 --save 在我的project.module.ts
ng : ui-switch is not a known element
ng : if ui-switch is An angular component then verify it's a part of this
module
要安装ui switch,我在Angular CLI中使用了以下命令:
npm install ngx-ui-switch@^1.6.0 --save
在我的project.module.ts中:
import { UiSwitchModule } from 'ngx-ui-switch';
import {ProjectsComponent} from './projects/projects.component';
import {NewProjectsComponent} from './new-projects/new-projects.component';
import { EditProjectComponent } from './projects/edit-project/edit-
project.component';
@NgModule({
imports: [FormsModule,
CommonModule,UiSwitchModule ,ProjetRoutingModule],
declarations: [ProjectsComponent,
NewProjectsComponent,
EditProjectComponent]
})
在project.component.html中,我写道:
<ui-switch></ui-switch>
有什么想法吗
Ps:我用的是角度5
编辑
结构如下:
您使用的是
1.6.0
,如中所述,它是针对angular v4的。由于angular 4对装饰器使用不同的元数据版本
超越角度v4
主分支将包含Angular最新版本的最新代码。将此库升级到Angular的新版本时,将创建一个新的x.y-stable分支以允许进行错误修复。下面是如何安装库的最新版本
这就是您想要做的:
npm install ngx-ui-switch --save
# yarn add ngx-ui-switch
您试图在哪个组件中使用
?您是否在使用inAppComponent
或其他组件?也许您应该重新阅读您引用的链接上的文档。您试图使用错误版本的库。哪个模块是project.component
的一部分?我在这个模块的声明中看不到它,我有一个名为project的目录,里面有project.module.ts和组件project.component.ts.html.css,可能是project.module.ts中缺少bootstrap:[ProjectComponent]
。(基于angular cli创建的标准app.module)感谢您的回答,现在问题已经解决,问题是我在project.module.ts.BTW中缺少引导:[ProjectComponent],我认为这不正确,由于ngx ui switch 1.6.0确实适用于Angular 5。事实上,我不知道,但作为第一个解决方案,我卸载了1.6.0版,并使用npm安装ngx ui switch—保存。