在使用RC5配置angular2-高级图表时,我得到以下错误
产品:15错误: TypeError:无法读取属性'type‘of null(…)(匿名函数)@ product:15ZoneDelegate.invoke @ zone.js:332Zone.run @zone.js:225(匿名函数)@ zone.js:586ZoneDelegate.invokeTask @ zone.js:365Zone.runTask @ zone.js:265drainMicroTaskQueue @ zone.js:491ZoneTask.invoke @ zone.js:435
我的系统is如下
/**
* 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 { }发布于 2016-08-19 14:53:40
您正在导入导入数组中的CHART_DIRECTIVES。imports数组专门用于导入模块,而不是其他任何东西。
因此,要么需要等待Angular2 -高级图表将它们的指令打包到Angular2 RC5模块中,然后只需导入该模块,要么现在需要将CHART_DIRECTIVES移动到“声明”数组中。
https://stackoverflow.com/questions/39041165
复制相似问题