【发布时间】:2017-09-01 13:13:09
【问题描述】:
我是打字稿的新手。基本上我有一个打字稿 GET 函数,我想传递一个 ID 来取回那个特定的记录。我在返回线上收到此错误。我在这里发布之前对此进行了研究,但无法获得接近我的场景的东西。感谢您的帮助!
错误 TS2349 无法调用其类型缺少调用的表达式 签名。
private getRecordRequestUrl = 'http://localhost/Service/api/ReservationRequest/GetRequestById';
getRecordRequest(RequestId: number): Promise<ReservationModel[]> {
return this.http.get(this.getRecordRequestUrl(RequestId))
.toPromise()
.then(response => response.json().Data as ReservationModel[])
.catch(this.handleError);
}
【问题讨论】:
-
getRecordRequestUrl是一个字符串。您正尝试在this.getRecordRequestUrl()中调用它。正是 TypeScript 警告你的错误类型,它确实存在。
标签: javascript angular typescript