错误systemjs使用angular2-highcharts
问题描述:
尝试配置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 { }
答
您正在导入数组中的CHART_DIRECTIVES。 imports数组专门用于导入模块,没有别的。
因此,您可能需要等待angular2-highcharts他们的指令打包成一个Angular2 RC5模块,你就可以简单地导入模块,或者您需要CHART_DIRECTIVES进入你的“声明”阵列现在
这看起来不像systemjs错误,你为什么认为这是错误的? –
谷歌开发者控制台显示错误行 – user93
是的,但基本上你的整个应用程序:)你能提供你的main.ts的代码? –