我一直坚持这个错误很长一段时间,我似乎无法在网上找到任何参考。关于什么是实际错误,没有行号或参考。 Illegal Constructor
看起来如此通用,我不知道如何使用它。任何帮助将不胜感激。
组件
import {Component, OnInit, Input} from "@angular/core";
import { Http, Response, HttpModule } from '@angular/http';
import Channelservice = require("../services/channel.service");
import {ChannelEvent} from "../services/channel.service";
import ChannelConfig = Channelservice.ChannelConfig;
import ChannelService = Channelservice.ChannelService;
import SignalrWindow = Channelservice.SignalrWindow;
import './rxjs-operators';
class Notification {
Id: number;
NotificationType: string;
Message: string;
Exception: string;
User: string;
TimeStamp: string;
}
@Component({
templateUrl: './random.html',
styleUrls: ['./random.css'],
providers: [ChannelService, SignalrWindow],
})
export class GasTroubleComponent implements OnInit {
@Input() eventName: string;
@Input() apiUrl: string;
timeStamp: string;
messages = "";
private channel = "tasks";
constructor(
private http: Http,
private channelService: ChannelService
) {
}
ngOnInit() {
this.channelService.sub(this.channel).subscribe(
(x: ChannelEvent) => {
switch (x.name) {
case this.eventName: { this.appendStatusUpdate(x); }
}
},
(error: any) => {
console.warn("Attempt to join channel failed!", error);
}
)
}
private appendStatusUpdate(ev: Channelservice.ChannelEvent): void {
this.timeStamp = `${ev.data.TimeStamp}`;
this.timeStamp = "Hello";
}
callApi() {
return this.http.get(this.apiUrl)
.map((res: Response) => res.json())
.subscribe((message: string) => { console.log(message); });
}
};
答案 0 :(得分:0)
我有同样的问题,我的很简单
我没有把括号括起来,而你的也似乎是同样的问题
您在末尾的“”“”“};”“”“”