json data
{ "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\"}]" }
Service
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 file
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>
Question
I want to set batch from json data to select box see json data above this comes from JsonConvert.SerializeObject how to convert normal array which access by ngFor
how to do it?