データベースからレコードを取得しようとしていますが、observablesと次のコードを書きましたが、records.Can誰も助けてください。Observableを使用してdbからデータをフェッチする方法
私のコンポーネントは、
import { Injectable } from '@angular/core';
import {Component} from '@angular/core';
import {Http, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import { IDetails } from './details';
@Component({
templateUrl: './components/search/search.html',
})
@Injectable()
export class Search {
details:IDetails[];
constructor(public http: Http) {
this.http = http;
}
submit(id):any{
var headers = new Headers();
var id = localStorage.getItem('social_id')
headers.append('Content-Type','application/x-www-form-urlencoded')
this.http.get('http://localhost/a2server/index.php/profile/search/'+id,{headers:headers})
.subscribe(
response => { <IDetails[]> response.json(); })
}
}
私は私のDBからレコードを取得しようとしています、私が観測を書き、次のコードで私はどのrecords.Can誰かが助けを提案してください取得しておりません。私の答えにあなたのコメントで
はあなたにダンに感謝、それはステップ観測 –
MMR
@nlr_pを使用する目的が何であるか、その後働いていた - 私はあなたが観察のために、なぜ必要コメントに求めていたと思います。私はそれを反映する答えを更新しました。 –