未定義の角度の「取得」プロパティを読み取ることができません。私のコードです: AppComponent.tsは、私は自分のアプリケーションのために異なるservice.tsに私の取得者を動かしていますが、私はここでは、この <a href="https://i.stack.imgur.com/ZNaoF.png" rel="nofollow noreferrer">error</a></p> <p>を得る2
import { Component } from '@angular/core';
import {Http } from '@angular/http';
import 'rxjs/Rx';
import {FeatureService} from "./Feature.service";
@Component({
selector: 'my-app',
providers: [FeatureService],
template: `<h1>Hier staat de json die we uit de test hebben gehaald</h1>
<p>Deze json hallen we van vert.x af en kunnen we converten naar een mooie rapport.</p>
<button (click)="clicked()">Haal test Json op</button>
<button (click)="getFeatures()">features</button>
<button (click)="getScenarios()">scenarios</button>
{{leerling}}
`,
})
export class AppComponent {
titel = "";
leerling: any;
leerlingUrl = 'http://localhost:8080/testresultaten';
public clicked(){
this.http.get(this.leerlingUrl).map(res => res.json())
.subscribe(data => this.leerling = JSON.stringify(data)
,error => this.leerling = "error",() => console.log("Json got good"));
}
public getFeatures(){
this.leerling = FeatureService.getFeature();
}
public getScenarios(){
this.http.get('http://localhost:8080/features/1/scenarios').map(res => res.json()).subscribe(data => this.leerling = JSON.stringify(data),error => this.leerling = "error",() => console.log("Json got good"));
}
constructor(private http : Http, private featureService : FeatureService){
}
}
そして、ここで私のFeature.service.ts
import {Http} from "@angular/http";
export class FeatureService{
private static http : Http;
static getFeature(){
return this.http.get('http://localhost:8080/features')
.map(data => data.toString());
}
}
古いもの((クリック)とgetScenarios())はまだ動作しますがフィーチャリングでありますureService.getFeatureは()
:(SystemJS)FeatureServiceのすべてのパラメータを解決できません: – Nick
import import 'Http'と' @Injectable'のために、私はそれが明らかだと思いました。私は答えによって更新しました。 – rzelek
ああ、ええ、非常に疲れて申し訳ありません。しかし、それは今非常に感謝して動作します – Nick