ngModule을 사용하여 가져 오기 및 기타 종속성을 그룹화합니다. 데이터 그리드로 ag 그리드를 사용하고 있습니다. 아래는 내 app.module.ts입니다.ngModule의 'AppModule'모듈에서 예기치 않은 'undefined'값을 가져 왔습니까?
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {SecurityContextService} from './securitycontext.service';
import { AppComponent } from './app.component';
import { HttpModule } from '@angular/http';
import {AgGridModule} from 'ag-grid-ng2/main';
import {HeaderComponent} from './app.header';
@NgModule({
imports: [ BrowserModule,HttpModule,AgGridModule],
declarations: [ AppComponent,HeaderComponent],
providers: [ SecurityContextService],
bootstrap: [ AppComponent ]
})
export class AppModule { }
다음과 같은 예외가 있습니다.
Unexpected value 'undefined' imported by the module 'AppModule'
아래의 예외 스택 추적입니다 -
Error: Error: Unexpected value 'undefined' imported by the module 'AppModule' at new BaseException (http://localhost:8000/lib/@angular/compiler/src/facade/exceptions.js:27:23) at eval (http://localhost:8000/lib/@angular/compiler/src/metadata_resolver.js:255:31) at Array.forEach (native) at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8000/lib/@angular/compiler/src/metadata_resolver.js:239:44) at RuntimeCompiler._compileComponents (http://localhost:8000/lib/@angular/compiler/src/runtime_compiler.js:150:47) at RuntimeCompiler._compileModuleAndComponents (http://localhost:8000/lib/@angular/compiler/src/runtime_compiler.js:72:37) at RuntimeCompiler.compileModuleAsync (http://localhost:8000/lib/@angular/compiler/src/runtime_compiler.js:49:21) at PlatformRef_._bootstrapModuleWithZone (http://localhost:8000/lib/@angular/core/src/application_ref.js:368:25) at PlatformRef_.bootstrapModule (http://localhost:8000/lib/@angular/core/src/application_ref.js:361:21) at execute (http://localhost:8000/app/main.js:16:65) Error loading http://localhost:8000/app/main.js
주 : 내 수입에 AgGridModule를 사용할 때 나는 단지이 예외를 얻을.
내 응용 프로그램을 빌드 할 때 gulp를 사용하고 있습니다. 당신이 AG-그리드 NG2을 사용하는 경우 그때,이 방법으로 문제가 해결됩니다 전적으로 모르겠지만,
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'rxjs': 'lib/rxjs',
'@angular': 'lib/@angular',
'ag-grid-ng2': 'lib/ag-grid-ng2',
'ag-grid-enterprise': 'lib/ag-grid-enterprise',
'ag-grid': 'lib/ag-grid',
'@angular/router': 'lib/@angular/router',
'angular2-in-memory-web-api': 'lib/angular2-in-memory-web-api',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': {main: 'main.js', defaultExtension: 'js'},
'rxjs': {defaultExtension: 'js'},
'ag-grid-ng2': {
defaultExtension: "js"
},
'ag-grid': {
defaultExtension: "js"
},
'ag-grid-enterprise': {
defaultExtension: "js"
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/router-deprecated',
'@angular/testing',
'@angular/upgrade',
'@angular/forms'
];
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function (pkgName) {
packages[pkgName] = {main: 'index.js', defaultExtension: 'js'};
});
var config = {
map: map,
packages: packages
};
// filterSystemConfig - index.html's chance to modify config before we register it.
if (global.filterSystemConfig) {
global.filterSystemConfig(config);
}
System.config(config);
빌드 용 또는 자체 빌드 시스템에 angular-cli를 사용하고 있습니까? 당신은 당신의 시스템 구성을 추가 할 수 있습니까 –
신속한 Madhu 주셔서 감사. systemjs 설정 세부 사항을 업데이트했습니다. – akash
이 게시물에 대한 내 응답을보십시오 : [http://stackoverflow.com/questions/39265561/error-unexpected-value-undefined-imported-by-the-module/42088538#42088538](http://stackoverflow.com/) 질문/39265561/예기치 않은 값 - 정의되지 않음 - 모듈에 의해 가져 오기/42088538 # 42088538) –