AGGrid - Angular2 - 对象不支持属性或方法' map'。 SystemJS

时间:2017-01-05 15:23:56

标签: angular systemjs ag-grid

当尝试简单地将AG网格模块包含到代码库中时,我得到错误"(SystemJS)对象不支持属性或方法' map' &#34 ;.还有其他东西需要包括在内吗? Angular2的AGGrid文档似乎没有提到这一点。这是一些相关的代码片段。我认为 AG grid / AG Grid 2已正确安装 - 是从npm install完成的,它包含在依赖项中。

Systemjs.config.js

        '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
        '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
        '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js,
        '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
        '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
        '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
        '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
        '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
        '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',

        // other libraries
        'rxjs': 'npm:rxjs',
        'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
        '@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',

        // ag libraries
        'ag-grid-ng2' : 'node_modules/ag-grid-ng2',
        'ag-grid' : 'node_modules/ag-grid', 

...

'ag-grid-ng2': {
            defaultExtension: "js"
        },
        'ag-grid': {
            defaultExtension: "js"
        }

app.module.ts

import { Component, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { JsonpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { HttpModule } from '@angular/http';
import './shared/rxjs-extensions';
import { HomeModule } from './home/home.module';
import { ProjectsModule } from './projects/projects.module';
import { OperationsModule } from './operations/operations.module';
import { AppRoutingModule, routableComponents } from './app-routing.module';
import { SharedModule } from './Shared/shared.module';
import { AgGridModule } from 'ag-grid-ng2/main';
import { Constants } from './Services/constants';
import { Configuration } from './Services/configuration';
import { ModalModule } from './Shared/modal/modal.module';

...

@NgModule({
    imports: [BrowserModule,
    HttpModule,
    SharedModule,
    FormsModule,
    HomeModule,
    ProjectsModule,
    OperationsModule,
    AppRoutingModule,
    ModalModule,
    AgGridModule.withComponents([])],
declarations: [AppComponent, routableComponents],
bootstrap: [AppComponent],
providers: [Constants, Configuration]

})

那么,我在这里错过了什么?

1 个答案:

答案 0 :(得分:0)

原来问题是我使用的是Angular2的旧版本。通过升级到2.4.x.事情开始奏效。