【发布时间】:2022-01-25 18:55:29
【问题描述】:
我正在关注此tutorial 在 Angular 应用程序中安装 Ngselect 模块,并在提供应用程序时出现此错误。我用谷歌搜索并找不到这里有什么问题。
模块“AppModule”导入的意外值“D:/ku-site/ku-web/node_modules/@ng-select/ng-select/lib/ng-select.module.d.ts”中的错误值“NgSelectModule”在 D:/ku-site/ku-web/ku-web/src/app/app.module.ts'。请添加@NgModule 注解。
app.module.ts
import { BrowserModule, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { NgSelectModule } from '@ng-select/ng-select';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserAnimationsModule,
NgSelectModule,
AppRoutingModule,
FormsModule
],
exports: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
编辑:我在简化问题代码时错过了import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core'; 行。
【问题讨论】:
-
导入NgModule后现在解决了吗?
-
No.. 仍然抛出同样的错误。
-
你是否也错过了 import { AppComponent } from './app.component'; 这行?
-
您使用的 angular 和 ng-select 版本是什么?
-
Angular: 9.1.3和"@ng-select/ng-select": "^8.1.1"。
标签: angular typescript select angular-ngselect