Angular 2错误'非法构造函数'

时间:2016-09-26 16:52:18

标签: angular

我一直坚持这个错误很长一段时间,我似乎无法在网上找到任何参考。关于什么是实际错误,没有行号或参考。 Illegal Constructor看起来如此通用,我不知道如何使用它。任何帮助将不胜感激。

这是错误图片 enter image description here

组件

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); });
   }
};

1 个答案:

答案 0 :(得分:0)

我有同样的问题,我的很简单

我没有把括号括起来,而你的也似乎是同样的问题

您在末尾的“”“”“};”“”“”