1
JSON數據
{ "d": "[{\"batch\":\"5\",\"term\":\"TERM V\",\"section\":\"Section I\"},{\"batch\":\"5\",\"term\":\"TERM VI\",\"section\":\"Section I\"},{\"batch\":\"5\",\"term\":\"TERM VII\",\"section\":\"Section I\"},{\"batch\":\"6\",\"term\":\"TERM I\",\"section\":\"Section I\"},{\"batch\":\"6\",\"term\":\"TERM II\",\"section\":\"Section I\"}]" }
服務來選擇框中
getwithParamter()
{
let params = {program: 'pravin'};
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json; charset=utf-8');
//this.headers.append('Parameter', params);
let options = new RequestOptions({
method: RequestMethod.Post,
url: "AttendanceMast.aspx/getBatch",
headers: this.headers,
body:{program: 'IFDM',location:'Pune',createdby:'ifdmpune'}
});
return this._http.request(new Request(options)).retry(2)
.map((response: Response) => JSON.parse(response.text()))
.do(data => console.log('All: ' + data))
.catch(this.handleError);
}
TS文件
this.dataService.getwithParamter().subscribe(
tradeshows => this.getwithparamter = tradeshows,
error => console.error('Error: ' + error)
);
HTML
Batch : <select [(ngModel)]="sel_batch" > <option >Select Batch</option>
<option *ngFor="let item of getwithparamter ">{{item.batch}}</option>
我想從json data
設置batch
到select box
見上此JSON數據來自JsonConvert.SerializeObject
如何轉換它通過ngFor
訪問正常陣列怎麼辦呢?
它很好地工作,但相關的過濾器功能不工作,顯示錯誤像原始異常:當我嘗試像 – Pravin
任何想法爲什麼這個錯誤顯示 – Pravin
我覺得可能是在getwithparamter檢索數據之前的過濾器調用是否有任何想法在變量檢索數據後調用過濾器 – Pravin