gpt4 book ai didi

angular - 模块 'DataTable' 导入的意外指令 'AppModule'

转载 作者:搜寻专家 更新时间:2023-10-30 22:01:24 24 4
gpt4 key购买 nike

我目前正在做一个简单的 angular 2 项目,我的所有导入都在我的 app.module.ts 中,如下所示

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 { }

我在我的终端窗口中没有任何错误,但是,在 chrome 的控制台窗口中我收到以下错误。

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

最佳答案

可能已经晚了,你已经想通了,但是关于AuthHttp,它不应该被导入,而是提供,看看angular2-jwt 基本配置:https://github.com/auth0/angular2-jwt

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

关于angular - 模块 'DataTable' 导入的意外指令 'AppModule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40003271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com