angular - 错误 TS1238 : Unable to resolve signature of class decorator when called as an expression. Angular

标签 angular angular-services

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

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:作为表达式调用时无法解析类装饰器的签名.

我也犯了同样的错误

enter image description here

有谁可以帮助我并谢谢你:)

最佳答案

改变

@Injectable

@Injectable()

关于angular - 错误 TS1238 : Unable to resolve signature of class decorator when called as an expression. Angular ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52391201/

相关文章:

node.js - 目标入口点 "@fullcalendar/angular"中的错误缺少依赖项

javascript - 在没有循环依赖的情况下重用服务

javascript - 在此 Angular 2 应用程序中,此跨组件通信 "pattern"究竟如何工作?

javascript - 删除字符串周围的括号并将内容放入新对象

angular - 无法绑定(bind)到 ':xlink:href',因为它不是 ':svg:image' 的已知属性

html - 如何在 Angular 2 中获得 mat-card-header 背景全色?

angular - 如何覆盖 Material 中的 matTreeNodePadding 样式?

javascript - 使用多个单选框禁用多个输入字段

AngularJS Controller /工厂返回 undefined object

javascript - Angular 指令未在 SVG 中呈现