【问题标题】:Image list in angular角度图像列表
【发布时间】:2020-10-21 06:09:37
【问题描述】:

我有一个包含 src 和标题的数组。我需要通过数组循环显示列表中的图像。

IMAGES = [
{
  src: 'https://material.angular.io/assets/img/examples/shiba2.jpg',
  caption: 'It\'s a thing',
},
{
  src: 'https://picsum.photos/200',
  caption: 'This is a really long string to see how the text will overflow',
},
{
  src: 'https://picsum.photos/200',
  caption: 'It\'s a thing',
},
{
  src: 'https://picsum.photos/200',
  caption: 'It\'s a thing',
},
{
  src: 'https://picsum.photos/200',
  caption: 'It\'s a thing',
},
{
  src: 'https://picsum.photos/200',
  caption: 'It\'s a thing',
}
];

【问题讨论】:

  • 您正在寻找*ngFor-directive

标签: angular image ngfor


【解决方案1】:

请检查以下代码,您可以使用 div 和内部 div img 标签。

<div *ngFor="let image of IMAGES">
    <img [src]="image.src" [attr.alt]="image.caption" [attr.title]="image.caption" width="100" height="100">
</div>

【讨论】:

    猜你喜欢
    • 2018-01-16
    • 1970-01-01
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 2019-09-17
    • 2020-02-15
    • 2021-04-12
    • 1970-01-01
    相关资源
    最近更新 更多