私はこのエラーが発生しており、私は新しいを2番にしていますので、問題を解決する方法は100%ではありません。いくつかのダミーデータを含むjavascriptオブジェクトを返す。しかし、私の "this.onGet()"関数は、指定されたパラメータが呼び出しターゲットのシグネチャと一致しないため、なぜ私がその理由を理解できないように見えるかを伝えています。 (基本的に私はAPIからの情報とORDERINFO配列を移入しようとしているので、私は、複数のページを渡ってそれを使用することができます)
すべてのヘルプ感謝:)"指定されたパラメータがコールターゲットのシグネチャと一致しません。 APIからの情報を収集するためにgetを使用しています
App.component.ts
import { Component, OnInit } from '@angular/core';
import { DetailsService } from './details.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [DetailsService]
})
export class AppComponent implements OnInit {
orderInfo = [
{
name: 'Test'
}
];
constructor(private detailsService: DetailsService) {
}
ngOnInit() {
this.onGet();
}
onGet(name: string) {
this.detailsService.getDetails()
.subscribe(
(orderData: any[]) => {
this.orderInfo.push({
name: name
});
console.log(orderData);
}
);
}
}
details.service.ts
import {Injectable} from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/Rx';
@Injectable()
export class DetailsService {
constructor(private http: Http) {}
getDetails() {
return this.http.get('http://swapi.co/api/people/1/?format=json', '')
.map(
(response: Response) => {
const orderData = response.json();
return orderData;
}
);
}
}
私はこれをやっていましたが、それは問題を引き起こしているようではありませんでした –