“ng-select”不是已知元素
‘ng-select’ is not a known element
我正在尝试将 select component 用于 angular,但在我按照说明配置模块后,抛出此错误。
错误
Uncaught Error: Template parse errors:
'ng-select' is not a known element:
1. If 'ng-select' is an Angular component, then verify that it is part of this module.
2. If 'ng-select' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
[ERROR ->] <ng-select placeholder="Select city"></ng-select>
我的app.module.ts怎么样:
...
import { NgSelectModule } from '@ng-select/ng-select';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [AppComponent],
entryComponents: [...],
imports: [..., NgSelectModule, FormsModule],
providers: [
...
],
bootstrap: [AppComponent]
})
export class AppModule {}
我尝试遵循 的解决方案,它有同样的错误,但即使我这样做,我也会得到这个错误。我还尝试将 NgSelectModule
导入并添加到我的页面模块中,但没有任何变化。我什至尝试将模块添加到 app-routing.module.ts
,因为我读到有人提到过,但也没有用。
附加信息:
Ionic CLI : 5.4.16
Ionic Framework : @ionic/angular 4.11.7
@angular-devkit/build-angular : 0.801.2
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
您是否仅在 AppModule 中使用 Ng-Select?因为如果你要在另一个中使用它,你还应该声明 NgSelectModule。
imports: [NgSelectModule]
简单重启开发环境,重新编译一切,大功告成!
我正在尝试将 select component 用于 angular,但在我按照说明配置模块后,抛出此错误。
错误
Uncaught Error: Template parse errors: 'ng-select' is not a known element: 1. If 'ng-select' is an Angular component, then verify that it is part of this module. 2. If 'ng-select' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. [ERROR ->]
<ng-select placeholder="Select city"></ng-select>
我的app.module.ts怎么样:
...
import { NgSelectModule } from '@ng-select/ng-select';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [AppComponent],
entryComponents: [...],
imports: [..., NgSelectModule, FormsModule],
providers: [
...
],
bootstrap: [AppComponent]
})
export class AppModule {}
我尝试遵循 NgSelectModule
导入并添加到我的页面模块中,但没有任何变化。我什至尝试将模块添加到 app-routing.module.ts
,因为我读到有人提到过,但也没有用。
附加信息:
Ionic CLI : 5.4.16
Ionic Framework : @ionic/angular 4.11.7
@angular-devkit/build-angular : 0.801.2
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
您是否仅在 AppModule 中使用 Ng-Select?因为如果你要在另一个中使用它,你还应该声明 NgSelectModule。
imports: [NgSelectModule]
简单重启开发环境,重新编译一切,大功告成!