I have following method in typescript, I need to bind to angular grid
CountryService
GetCountries() {
return this.http.get(`http://services.groupkt.com/country/get/all`)
.map((res:Response) => <CountryData[]>res.json().RestResponse["result"]);
}
GridComponent
template: `
<ag-grid-ng2 style="width: 100%" #agGrid class="ag-material"
rowHeight="50"
[gridOptions]="myGridOptions"
>
</ag-grid-ng2>
`,
this.myGridOptions.rowData= this.CountryService.GetCountries();
CountryData
export class CountryData{
name: string;
alpha2_code: string;
alpha3_code: string;
}
But GetCoutries will return Observable of any, unable to bind to rowData?
How to convert Observable to CountryData[] in typescript ?
you find JSON data here: http://services.groupkt.com/country/get/all
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…