2016-08-19 81 views
1

嘗試配置angular2-highcharts與RC5錯誤systemjs使用angular2-highcharts

product:15 Error: TypeError: Cannot read property 'type' of null(…)(anonymous function) @ product:15ZoneDelegate.invoke @ zone.js:332Zone.run @ zone.js:225(anonymous function) @ zone.js:586ZoneDelegate.invokeTask @ zone.js:365Zone.runTask @ zone.js:265drainMicroTaskQueue @ zone.js:491ZoneTask.invoke @ zone.js:435

我systemjs時,我得到了以下錯誤如下

/** 
* System configuration for Angular 2 samples 
* Adjust as necessary for your application needs. 
*/ 
(function(global) { 
    // map tells the System loader where to look for things 
    var map = { 
    'app':      'app', // 'dist', 
    '@angular':     'node_modules/@angular', 
    'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', 
    'rxjs':      'node_modules/rxjs', 
    'angular2-highcharts':  'node_modules/angular2-highcharts/dist', 
    'highcharts/highstock.src': 'node_modules/highcharts/highstock.js' 
    }; 
    // 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' }, 
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }, 
    'angular2-highcharts' :  { main: 'index', defaultExtension: 'js' } 
    }; 
    var ngPackageNames = [ 
    'common', 
    'compiler', 
    'core', 
    'forms', 
    'http', 
    'platform-browser', 
    'platform-browser-dynamic', 
    'router', 
    'router-deprecated', 
    'upgrade', 
    ]; 
    // Individual files (~300 requests): 
    function packIndex(pkgName) { 
    packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' }; 
    } 
    // Bundled (~40 requests): 
    function packUmd(pkgName) { 
    packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; 
    } 
    // Most environments should use UMD; some (Karma) need the individual index files 
    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; 
    // Add package entries for angular packages 
    ngPackageNames.forEach(setPackageConfig); 
    var config = { 
    map: map, 
    packages: packages 
    }; 
    System.config(config); 
})(this); 

這是我的app.module。 ts

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule } from '@angular/forms'; 
import { routing }  from './app.routing'; 
import { AppComponent } from './app.component'; 
import { ProductDetail } from './detail.component'; 
import { CHART_DIRECTIVES } from 'angular2-highcharts'; 

@NgModule({ 
    imports:  [ BrowserModule, routing,FormsModule , CHART_DIRECTIVES], 
    declarations: [ AppComponent,Detail ], 
    exports:[Detail], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { } 
+0

這看起來不像systemjs錯誤,你爲什麼認爲這是錯誤的? –

+0

谷歌開發者控制檯顯示錯誤行 user93

+0

是的,但基本上你的整個應用程序:)你能提供你的main.ts的代碼? –

回答

2

您正在導入數組中的CHART_DIRECTIVES。 imports數組專門用於導入模塊,沒有別的。

因此,您可能需要等待angular2-highcharts他們的指令打包成一個Angular2 RC5模塊,你就可以簡單地導入模塊,或者您需要CHART_DIRECTIVES進入你的「聲明」陣列現在

相關問題