2017-05-23 2 views
-2

サーバーから最初のionicアプリケーションでデータを取得しようとしましたが、エラーが発生しました。コードスニペットが付いたプロパティを読み取れません。ここに私のコードは次のとおりです。出力のイオンでデータを取得する

import { Component } from '@angular/core'; 
import { NavController } from 'ionic-angular'; 
import { Http} from '@angular/http'; 
import 'rxjs/add/operator/map' 

@Component({ 
selector: 'page-test', 
templateUrl: 'test.html' 
}) 
export class TestPage { 

posts: any; 

constructor (public navCtrl: NavController, public http: Http) { 

    this.http.get.('http://localhost/AppApis/salesheader.php').map(res => res.json()).subscribe(response => { 

    console.log(response.object.object.object.cardname)}); 

} 
) 

スクリーンショット:

+2

?これにより、他の人があなたを助けやすくなります。 –

+0

コードのスクリーンショットを投稿しないでください。真剣に、私は人々がこれを続けている理由を理解していない。それは明白ではありませんか? –

答えて

0

私が問題に

service.ts

を解決this.I希望のようなデータを取ってきました
getdata() { 

    var response = this.http.get('http://xxxxxx').map(res => res.json()); 
     console.log(response); 
     return response; 

}

test.tsあなたがあなたの質問にあなたのコードを貼り付け/くださいコピーでし

getdata:any; 

    constructor(public navCtrl: NavController, public navParams: NavParams,public service:Service,public http : Http) {} 

    this.service.getdata().subscribe(
        data=>{ 

        this.getdata = data; 


        }); 
関連する問題