模块'AppModule'声明的意外模块'Ng2SmartTableModule'

Wir*_*Xie 3 components ng2-smart-table angular

我正试图从这个链接学习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'
      }
    }
  };
}
Run Code Online (Sandbox Code Playgroud)

和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 { }
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个错误吗?

提前致谢.

Saj*_*ran 6

由于这是一个模块,你需要添加里面imports没有根据declarations

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent

  ],
  imports: [
    BrowserModule,
    Ng2SmartTableModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)