如何像enter image description here一样显示信息
这张照片?
const DISH = {
id: '0',
name: 'Uthappizza',
image: '/assets/images/uthappizza.png',
category: 'mains',
featured: true,
label: 'Hot',
price: '4.99',
// tslint:disable-next-line:max-line-length
description: 'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
comments: [
{
rating: 5,
comment: 'Imagine all the eatables, living in conFusion!',
author: 'John Lemon',
date: '2012-10-16T17:57:28.556094Z'
},
{
rating: 4,
comment: 'Sends anyone to heaven, I wish I could get my mother-in-law to eat it!',
author: 'Paul McVites',
date: '2014-09-05T17:57:28.556094Z'
},
{
rating: 3,
comment: 'Eat it, just eat it!',
author: 'Michael Jaikishan',
date: '2015-02-13T17:57:28.556094Z'
},
{
rating: 4,
comment: 'Ultimate, Reaching for the stars!',
author: 'Ringo Starry',
date: '2013-12-02T17:57:28.556094Z'
},
{
rating: 2,
comment: 'It\'s your birthday, we\'re gonna party!',
author: '25 Cent',
date: '2011-12-02T17:57:28.556094Z'
}
]
};似乎什么都不起作用..
发布于 2020-07-11 03:20:11
下面是stackblitz:https://stackblitz.com/edit/angular-ivy-jvnlfw
你必须在angular中使用ngFor来迭代DISH.comments。
<div *ngFor="let data of this.sampleData.comments">
<p>
{{data.comment}}
</p>
<span *ngIf="data.rating">{{data.rating}} star</span>
<span>...{{data.author}}</span>
</div>https://stackoverflow.com/questions/62840624
复制相似问题