angular - 我如何以角度显示这些对象
问题描述
下面是JSN数据的图片:
网络服务.ts
myQuote = 'http://quotes.rest/qod.json';
getQuotes(){
return this.http.get(this.myQuote).subscribe(data => {
// data = const quotes;
console.log(data)
});
}
home.component.ts
@Component({
selector: 'messages',
template: ' here {{contents?.quotes[0].quote}}'
})
export class MessagesComponent {
constructor(private webService: webServices){}
showQuotes(){
this.webService.getQuotes();
var items = {}
}
ngOnInit(){
console.log(this.showQuotes())
}
}
解决方案
根据假设,根据您的屏幕截图:
HTML:
<div *ngFor="let obj of data.contents.quotes">
<div> {{obj.propertyName_that_you_want_display }} </div>
<h2>Options:</h2>
<div *ngFor="let tag of obj.tags">
{{tag}}
</div>
</div>
推荐阅读
- java - 如何在 adnroid 中获取 recyclerView 项目的 X 和 Y 坐标?
- android-fragments - 带有 RecyclerView 滚动问题的垂直 ViewPager2
- android - Android : Branch SDK Api Error after changed date on device
- python - fuzzywuzzy match in python with if condition
- python - 使用小部件在 jupyter notebook 中显示 gif
- php - bootstrap 4 折叠打开同一张卡
- ios - Firebase user merge Apple account into existing one
- reactjs - Passing functions to props.children
- java - Is there any way to use an interface non staticly
- node.js - How do I make GraphQL subscriptions in NodeJS via Apollo Client?