错误:模块导出的意外值'undefined'

时间:2017-07-02 17:22:57

标签: angular

我正在使用cli构建一个角度4应用程序。我创建了一个共享模块,并在我的appmodule和moviemodule中导入了该模块。我收到编译时错误未捕获错误:模块'SharedModule'导出的意外值'undefined'

有人能告诉我问题是什么,我仔细检查了语法。我在这里遗漏了什么

错误消息

enter image description here

共享模块

import { NgModule }            from '@angular/core';
import { CommonModule }        from '@angular/common';
import { FormsModule }         from '@angular/forms';
import { GridModule } from '@progress/kendo-angular-grid';


@NgModule({
  imports:      [ CommonModule
                    , GridModule ],

  exports:      [ 
                    , CommonModule
                    , FormsModule 
                    , GridModule 
                    ]
})
export class SharedModule { }

应用模块

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 { NavbarComponent } from './navbar/navbar.component';
import { TopbarComponent } from './topbar/topbar.component';
import { FooterbarComponent } from './footerbar/footerbar.component';
import { MRDBGlobalConstants } from './shared/mrdb.global.constants';
import {AppRoutingModule} from './app.routing';
import {HomeComponent} from './home/home.component';
import {MovieComponent} from './movie/movie.component';
import { MRDBCommonService } from './shared/services/mrdb.common.service';
import { NotFoundComponent } from './not-found/not-found.component';
import { SharedModule } from './shared/shared.module';


@NgModule({
  declarations: [
    AppComponent,
    FooterbarComponent,
    TopbarComponent,
    NavbarComponent,
    MovieComponent,
    HomeComponent,
    NotFoundComponent  
  ],
  imports: [
    BrowserModule,
    HttpModule,
    SharedModule,
    AppRoutingModule
  ],
  providers: [MRDBGlobalConstants,
              MRDBCommonService],
  bootstrap: [AppComponent]
})
export class AppModule { }

电影模块

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MovieComponent} from './movie.component';
import { SharedModule }    from '../shared/shared.module';

@NgModule({
  imports: [
       SharedModule
  ],
  exports: [MovieComponent],
  declarations: [MovieComponent]
})
export class MovieModule { }

2 个答案:

答案 0 :(得分:7)

删除CommonModule

的逗号前面
exports: [ 
 remove this => , CommonModule 
                , FormsModule 
                , GridModule 
            ]

答案 1 :(得分:0)

  1. 请尝试从SharedModule中的导出中删除网格模块。错误中的foreach可能是从网格模块中出来的,我假设网格模块正在尝试遍历某些数据。
  2. 在列出第一个模块
  3. 之前,导出部分中有一个额外的逗号