我正在尝试从这个 link 中学习 ng2 智能表我得到了这个错误。
未捕获错误:模块“AppModule”声明的意外模块“Ng2SmartTableModule”。请添加@Pipe/@Directive/@Component 注解。
这是 app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
//templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
//template: `<ng2-smart-table [settings]="settings"></ng2-smart-table>`
})
export class AppComponent {
//title = 'app';
settings = {
columns: {
id: {
title: 'ID'
},
name: {
title: 'Full Name'
},
username: {
title: 'User Name'
},
email: {
title: 'Email'
}
}
};
}
和 app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
Ng2SmartTableModule
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
谁能帮我解决这个错误?
提前致谢。
最佳答案
因为它是一个模块,你需要在 imports
里面添加,而不是在 declarations
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
Ng2SmartTableModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
关于angular - 模块 'Ng2SmartTableModule' 声明的意外模块 'AppModule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46841424/