Reputation: 49
Block of code in modal:
export class Profile {
constructor(public id : number,public name : string, public age: number,public address:any)
}
Block of code in TypeScript file:
profile : Profile[]= [new Profile(1,'hello',4,'address'),new Profile(1,'hello',4,'address'),
new Profile(1,'hello',4,'address'),new Profile(1,'hello',4,'address')
];
How to get name id age as a list and navigate through JSON object array, because following block of code is not displaying anything as it is an array of objects in JSON:
<div *ngFor="let p of profile">
<ion-button>{{p.id}}</ion-button>
</div>
Upvotes: 0
Views: 2823
Reputation: 955
For this particular problem, it is better to use interface
:
interface Profile {
id : number;
name : string;
age: number;
address:any;
}
now use it like so :
let profile : Profile[] = [{id : 1 , name : "Shahab" , age : 23 , adress : "Some where"} , ...]
Now you can access it easily .
Upvotes: 2