eddie eddie -4 years ago 152
TypeScript Question

Typescript JSON

My question can be stupid but I have to post.I am totally new to Typescript, I have this query that I have JSON data as below:
[{"regionID":1 "regionname":"Can"},

{"regionID":2 "regionname":"Cen"}]

I want to fetch the above data using typescript and display it in table format like:

region_id | Region name
1 | CAN
2 | CEN

Can anyone help me in this ,
Any help Appreciated

Thanks in advance.

Answer Source

Try this,

export class MyComponent{

   myData:any; ///Declare Variable



// Suppose your data is returned this way.
get(url) {
   return this._http.get(url, { headers: headers })
        .map(res => res.json())
         data => {
            this.myData = data;


        <th>region_id </th>
        <th>Region name</th>
        <tr *ngFor="let item of myData">

Hope it helps,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download