首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用带有角2的高图时的错误

使用带有角2的高图时的错误
EN

Stack Overflow用户
提问于 2016-09-22 12:03:36
回答 1查看 1.6K关注 0票数 0

我正在使用Angular2-高图表component.ts文件如下所示:

代码语言:javascript
复制
import { Component } from '@angular/core';
import { CHART_DIRECTIVES } from 'angular2-highcharts';

@Component({
    selector: 'emotions',
    templateUrl: 'app/components/emotions/emotions.component.html',
    providers: [EmotionsService],
    directives: [CHART_DIRECTIVES]

})
export class EmotionsComponent {
    constructor(private emotionsService: EmotionsService) {
        this.options = {
            title : { text : 'simple chart' },
            series: [{
                data: [29.9, 71.5, 106.4, 129.2],
            }]
        };
    }
    options: HighchartsOptions;
}

在我的模板文件中

代码语言:javascript
复制
<chart [options]="options"></chart>

package.json文件与其他角度依赖项一起具有以下内容:

代码语言:javascript
复制
"dependencies": {
    "angular2-highcharts": "0.2.1"
  },

我已经运行了npm install和angular2-高级图表已经安装在node_modules文件夹中。

我得到以下错误:

代码语言:javascript
复制
zone.js:1274 GET http://localhost:3000/angular2-highcharts 404 (Not Found)

我试图将systemjs.config.js文件更改为

代码语言:javascript
复制
map: {
            'angular2-highcharts': 'node_modules/angular2-highcharts'
}

但是,我开始收到以下错误:

代码语言:javascript
复制
zone.js:1274 GET http://localhost:3000/node_modules/angular2-highcharts/ 404 (Not Found)

我如何解决这个问题?

编辑

我在system.config.js文件中添加了这个

代码语言:javascript
复制
map:{
'angular2-highcharts': 'node_modules/angular2-highcharts/node_modules/highcharts/index.js',
}

我得到以下错误

代码语言:javascript
复制
zone.js:1274 GET http://localhost:3000/node_modules/angular2-highcharts/dist/index 404 (Not Found)

我试着改变了index -> index.js。它可以在上面工作,但是在其他js文件上也会出现同样的错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-23 03:19:58

我做了以下事情:

systemjs.config.js

代码语言:javascript
复制
map: {
            // our app is within the app folder
            app: 'app',
            'angular2-highcharts': 'node_modules/angular2-highcharts',
            'highcharts': 'node_modules/highcharts'
}

packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            'angular2-highcharts': {
                main: './index.js',
                defaultExtension: 'js'
            },
            'highcharts': {
                defaultExtension: 'js'
            }
}

从组件文件中删除指令

app.module.ts文件中添加以下内容

代码语言:javascript
复制
import { CHART_DIRECTIVES } from 'angular2-highcharts';
@NgModule({
    declarations: [
        CHART_DIRECTIVES
    ],
})
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39638550

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档