【问题标题】:error TS1238: Unable to resolve signature of class decorator when called as an expression. Angular错误 TS1238:作为表达式调用时,无法解析类装饰器的签名。角
【发布时间】:2018-09-18 16:45:27
【问题描述】:

我的项目有问题,但我不知道问题出在哪里。我想在我的项目中添加一个服务,我这样定义这个服务

import {Injectable} from "@angular/core";
import {Http} from "@angular/http";

@Injectable

export class ContactService{

constructor(public http: Http){

}
  getContacts(){
     return this.http.get("http://localhost:8080/findPersons? 
      mc=wa&page=1&size=6").map(resp => resp.json());
}
}

在我的 IDE 的控制台中我有这个错误 错误在 src/contact.service/contacts.service.ts(4,1): 错误 TS1238: Unable to resolve signature of class decorator when called as an expression .

我也犯了同样的错误

有没有人可以帮助我,谢谢:)

【问题讨论】:

    标签: angular angular-services


    【解决方案1】:

    改变

    @Injectable
    

    @Injectable()
    

    【讨论】:

      【解决方案2】:

      适用于 angular 4、5 或 6 的版本 我按照此页面更新我的版本并将运行

      Angular Injectable decorator - Expected 0 arguments but got 1

      谢谢我的朋友

      【讨论】:

        猜你喜欢
        • 2019-04-18
        • 2016-04-02
        • 2018-12-03
        • 2020-01-30
        • 2016-07-26
        • 2021-07-06
        • 1970-01-01
        • 2016-10-08
        • 2020-09-07
        相关资源
        最近更新 更多