html - 如何使用 Angular 在 HTML 中访问没有键名的数组对象
问题描述
我正在使用 Angular 7 和 Spring boot 5 开发一个网页。
所以,使用服务,我有这个数组数组:
我想在 html 组件的表格中显示它。我不知道如何访问每个项目(例如“Estanteria 2”),因为它没有键名。
有没有办法在没有键名的情况下访问 html 中的这些数据?
解决方案
这将取决于您希望如何在视图中显示它。
你有一个数组数组。所以要Estanteria 2
在 HTML 中显示,这样的事情就可以了;
<div *ngFor="let item of array">
<!-- this will show Estanteria 2 -->
<div>{{ item[3] }}</div>
</div>
如果你想遍历第二个数组中的所有值,你可以:
<div *ngFor="let item of array">
<!-- this will show all the values in the second array -->
<div *ngFor="let value of item">{{ value }}</div>
</div>
推荐阅读
- python - 为什么 sklearn cross_validate() 改装?
- qt - QML - GridLayout - 无法使用它来居中页面
- symfony - 未找到 ID id(45) 的“App\Entity\Slider”类型实体
- python - Plotly 的锥体颜色问题
- html - 按需显示图像
- r - 在 ggplot2 中添加小刻度的快速、时尚和简单的方法?
- python - 如何根据列条件在python中调整文本来绘制不同的颜色和样式
- mysql - MySQL AUTO_INCREMENT 不起作用:ER_NO_DEFAULT_FOR_FIELD:字段 'id' 没有默认值
- html - 选择框不遵循 css 样式?
- asp.net - 是否可以偏离标准 Acumatica 页面布局选项?