I am learning angular2 and typescript and wondering why I can not access property values of the object in my template.
My component:
export class Farm{
data:JSON;
id: any;
constructor(private nextService: NextService, navParams: NavParams){
this.id = navParams.get("param1");
}
getFarmDetails(){
this.data = this.nextService.fetchData(this.id)
console.log(this.data)
}
}
where console.log(this.data) gives me Object {id: 1, name: "Leanne Graham", username: "Bret", email: "[email protected]", address: Object…}
In my template I have
<div>
{{data}}
</div>
which outputs on my screen as [object Object]
How can I instead output properties like email or username?
UPDATE: If I do like {{data.email}} I get following error:
