I am making an AngularJS 2 application with the beta version. I want to show a JSON representation of an object in my page, but it shows [Object Object]
and not {key1:value1 ....}
From the component I can use:
get example() {return JSON.stringify(this.myObject)};
and then in the template:
{{example}}
but if I have an array of objects and would like to print a list of these objects, how I can do it?
Using:
<ul>
<li *ngFor="#obj of myArray">{{obj}}</li>
</ul>
results in something like:
- [Object Object]
- [Object Object]
- [Object Object]
- [Object Object]
and so on. Is there a way to display those as JSON?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…