2016-10-12 93 views
1

我目前工作的一個簡單的角2的項目,我有我的app.module.ts內的所有進口如下意外指令「數據表」由模塊進口「的AppModule」

import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { FormsModule } from '@angular/forms'; 
import { HttpModule } from '@angular/http'; 

import { AppComponent } from './app.component'; 
import { StockListComponent } from './stock-list/stock-list.component'; 

import { routing } from "./app-routing.module"; 
import { StockItemComponent } from './stock-item/stock-item.component'; 
import { ProfileComponent } from './profile/profile.component'; 
import { DeviceConfigurationComponent } from './device-configuration/device-configuration.component'; 
import { StockStatusComponent } from './stock-status/stock-status.component'; 


import {Calendar, Dialog, Button, InputSwitch, Dropdown, Growl, DataTable, SelectButtonModule} from 'primeng/primeng'; 
import {JwtHelper, AuthHttp, tokenNotExpired} from "angular2-jwt"; 

import {AuthService} from './auth.service'; 
import {DataService} from './data.service'; 

@NgModule({ 
declarations: [ 
    AppComponent, 
    StockListComponent, 
    StockItemComponent, 
    ProfileComponent, 
    DeviceConfigurationComponent, 
    StockStatusComponent 
], 
imports: [ 
    BrowserModule, 
    FormsModule, 
    HttpModule, 
    routing, 
    DataTable, 
    Calendar, 
    Dialog, 
    Button, 
    InputSwitch, 
    Dropdown, 
    Growl, 
    JwtHelper, 
    AuthHttp, 
    SelectButtonModule 
], 
providers: [ 
    AuthService, 
    DataService 
], 
bootstrap: [AppComponent] 
}) 
export class AppModule { } 

我不但是,在我的終端窗口中的任何錯誤,在鉻的控制檯窗口中,我收到以下錯誤。

metadata_resolver.js:227Uncaught Error: Unexpected directive 'DataTable' imported by the module 'AppModule'(…) 
(anonymous function) @metadata_resolver.js:227 
CompileMetadataResolver.getNgModuleMetadata @metadata_resolver.js:212 
RuntimeCompiler._compileComponents @runtime_compiler.js:130 
RuntimeCompiler._compileModuleAndComponents @runtime_compiler.js:68 
RuntimeCompiler.compileModuleAsync @runtime_compiler.js:59 
PlatformRef_._bootstrapModuleWithZone @application_ref.js:302 
PlatformRef_.bootstrapModule @ application_ref.js:284 
(anonymous function) @ main.ts:12 
__webpack_require__ @ bootstrap fbc4961…:52 
(anonymous function) @ zone.js:1327 
__webpack_require__ @ bootstrap fbc4961…:52 
webpackJsonpCallback @ bootstrap fbc4961…:23 

(匿名函數)@ main.bundle.js:1

+2

你正在使用什麼版本的'primeng'?它看起來像他們從舊的'DataTable'更新到更新的模塊模式:'DataTableModule' –

+0

但即時通過AuthHttp jwt import導致同樣的錯誤 – gurps

回答

0

可能爲時已晚,並且你已經理解了它,但對於AuthHttp,它不應該進口,而是提供,看看angular2-jwt基本配置:https://github.com/auth0/angular2-jwt

@NgModule({ 
    providers: [{ 
     provide: AuthHttp, 
     useFactory: authHttpServiceFactory, 
     deps: [Http, RequestOptions] 
    }] 
}) 
相關問題