Angular 意外值';装饰工厂';由模块导入';TempModule';
在我的示例应用程序中,我编写了一个功能模块“TempModule”和 下面是代码Angular 意外值';装饰工厂';由模块导入';TempModule';,angular,Angular,在我的示例应用程序中,我编写了一个功能模块“TempModule”和 下面是代码 import { NgModule } from '@angular/core'; import { CommonModule} from '@angular/common'; import { TempOneComponent } from './temp.one.component'; import { TempTwoComponent } from './temp.two.component'; impor
import { NgModule } from '@angular/core';
import { CommonModule} from '@angular/common';
import { TempOneComponent } from './temp.one.component';
import { TempTwoComponent } from './temp.two.component';
import { tempRouting } from './temp.routing';
@NgModule({
declarations: [ TempOneComponent,
TempTwoComponent],
imports: [ NgModule,
CommonModule,
tempRouting]
})
export class TempModule {}
我指的是根模块中的TempModule,下面是根模块代码
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
//-- routing import
import { routing,
appRoutingProviders} from './app.routing';
//-- root component import
import { AppComponent } from './app.component';
import { AppAboutComponent } from './app-about.component';
import { AppCreatTicketComponent } from './tickets/ app.create-ticket.component';
import { AppOpenTicketComponent } from './tickets/app.open-ticket.component';
import { AppSearchTicketComponent } from './tickets/ app.search-ticket.component';
import { AppDashboardComponent } from './tickets/app.dashboard.component';
import { AppUsersComponent } from './users/app.users.component';
import { TempModule } from './tempModule/temp.module';
@NgModule({
declarations: [AppComponent ,
AppAboutComponent ,
AppCreatTicketComponent,
AppOpenTicketComponent,
AppSearchTicketComponent,
AppDashboardComponent,
AppUsersComponent
],
imports: [BrowserModule ,
FormsModule ,
routing,
TempModule ],
providers: [appRoutingProviders],
bootstrap: [AppComponent]
})
export class AppModule {}
当我运行应用程序时,“由模块“TempModule”导入的意外值“DecoratorFactory”将显示在浏览器控制台中
知道这个错误的原因是什么吗?您正试图在
导入数组中导入装饰程序。它应该只包含模块
@NgModule({
declarations: [ TempOneComponent,
TempTwoComponent],
imports: [ NgModule, <== why is it here???
CommonModule,
tempRouting]
})
export class TempModule {}
@NgModule({
声明:[TempOneComponent,
(组件),,
导入:[NgModule,查看此错误的另一种方法是从错误的位置导入模块。例如:
import {CommonModule} from '@angular/core'; // wrong
应该是:
import {CommonModule} from '@angular/common';
通过在hero detail组件中添加以下代码解决了此问题
import { NgModule } from '@angular/core';
现在它工作了,实际上连错误描述都是这么说的,但是我没有费心去理解它。。