我试图建立一个应用程序,我在遇到障碍后遇到障碍,就在我认为我突破时,我不会。现在,一旦我引入了ng2-charts.js,曾经接受过AppComponent的应用程序现在却没有。我收到此错误:
我使用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在子组件中使用并在子组件中声明,但我注释掉子组件中的代码以确保这不是问题。任何有关这方面的帮助将不胜感激。