【发布时间】:2017-07-26 07:44:25
【问题描述】:
我试图弄清楚为什么在运行我的 ionic 2 项目时出现以下错误:
提供的参数与调用目标的任何签名都不匹配。 (第 16 行)
它指向的代码如下:
card.servce.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { Card } from "./cards";
@Injectable()
export class CardService {
private cardsUrl = 'my_url_here';
constructor(private http: Http) {}
getCards(): Promise<Card[]> {
return this.http.get(this.cardsUrl) // Error is here
.toPromise()
.then(response => response.json().cards as Card[])
.catch(...);
}
}
不知道为什么会出现此错误,是否缺少以下参数:
this.http.get(this.cardsUrl)?
Angular 核心:2.2.1
【问题讨论】:
-
试试
private cardsUrl:string = 'my_url_here'; -
@suraj 同样的问题。
标签: angularjs angular typescript ionic2 angular-http