0

我正在尝试构建一个应用程序,但我遇到了一个又一个的障碍,而就在我认为我突破的时候,我没有。现在,曾经接受 AppComponent 的应用程序,一旦我介绍了 ng2-charts.js,现在不接受了。我收到此错误:

在此处输入图像描述

我正在使用 System.js 和 Node.js 来运行这个应用程序。我已经卸载并重新安装了我的节点模块文件夹。这是我app.module.ts和我的 app.component.ts 文件:

app.module.ts

import {NgModule} from "@angular/core";
import {BrowserModule} from "@angular/platform-browser";
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {AppComponent} from "./app.component";
import TwitterService from "./twitter.service";
import BarGraphComponent from "./bar-graph.component";
import LineGraphComponent from "./line-graph.component";
import { ChartsModule } from "ng2-charts";
import {DataService} from "./data.service";

@NgModule({
    imports: [BrowserModule, FormsModule, HttpModule, ChartsModule ],
    declarations: [AppComponent, BarGraphComponent, LineGraphComponent],
    bootstrap: [AppComponent],
    providers: [TwitterService, DataService]
})
export default class AppModule { }

app.component.ts

import {Component, OnInit} from "@angular/core";
import * as io from "socket.io-client";
import {DataService} from "./data.service";
import TwitterService from "./twitter.service";
import {IoToken} from "./di";

@Component({
    selector: "app",
    templateUrl: "/app/app.component.html",
    providers: [TwitterService, DataService, {provide: IoToken, useValue: io}]
})

export class AppComponent implements OnInit {

    constructor(private twitter: TwitterService, private data: DataService) {}

    topWords = this.data.topWords;
    topWordsCount = this.data.topWordsCount;
    topHashtags = this.data.topHashtags;
    topHashtagsCount = this.data.topHashtagsCount;
    tweets = this.data.tweets;
    tweetsOverTime = this.data.tweetsOverTime;

    getTweetCount = () => this.data.totalCount;

    ngOnInit(){
        this.data.setSource(this.twitter.startStreaming());
    }
}

需要注意的是,socket.io 在子组件中使用和声明,但我注释掉了子组件中的代码以确保这不是问题。对此的任何帮助将不胜感激。

4

0 回答 0