Ionic2 提供的参数与调用目标的任何签名都不匹配

Ionic2 Supplied parameters do not match any signature of call target

我想弄清楚为什么在 运行 我的 ionic 2 项目时出现以下错误:

Supplied parameters do not match any signature of call target. (Line 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

getCards() return 是一个完整的承诺,但根据 return 类型定义,它应该 return 只是一个承诺:

选项 1:

getCards(){
    return this.http.get(this.cardsUrl)
        .toPromise()
        .then(response => response.json().cards as Card[])
        .catch(...);
    }

选项 2:

getCards(): Promise<Card[]>  {
        return this.http.get(this.cardsUrl)
                .toPromise();
    }

// use this function returnResult()

returnResult(){
    this.getCards().then(response => response.json().cards as Card[])
                .catch(...);
}