html - SelectedIndex in two dimensional array
问题描述
<div class="outer" *ngFor="let place of hallPlace; let i = index">
<div [ngClass]="{'seat-reserve' : selectedIndex === (j*i)+j}" class="inner" *ngFor="let spot of place; let j = index" (click)="setPlace((j*i)+j)">
<span class="content">{{spot}}</span>
</div>
</div>
setPlace(seat) {
this.selectedIndex = seat;
}
I have two dimensional array and I want to add class to selected item, now when I click first element add me style to 1 column, and also when i click random element add me style to few elements. How to add style only one element? And It is possible use array of selectedIndex?
解决方案
问题是索引计数以 开头0
,如果乘以 0,则得到 0
所以尝试((j+1) * (i+1)) + j + 1
而不是(j*i)+j
推荐阅读
- javascript - 材料-ui
组件的 100% 宽度的子组件与父组件重叠 - java - JPanel 未出现在 JFrame 中
- npm - 无法安装 npm 范围包
- ios - 类型“UIView”没有成员“layoutFittingCompressedSize”
- dynamics-crm - 在调查响应中填充联系人和机会查找
- ios - 给定四边形的四个角位置,填充四边形之外的所有内容
- python - Azure 存储关闭自动解压
- android - 如何连续读取logcat并写入内部存储文件?
- python - 带有 tf 数据集输入的 TensorFlow keras
- javascript - Google 电子邮件脚本更改日期