javascript - 如何显示/隐藏而不是切换图标?
问题描述
我需要显示/隐藏图标,而不是现在切换图标。代码:
<td *ngIf="isActive !== i" (click)="clickerTrue(set, i)">
<img src="https://img.icons8.com/office/30/000000/plus.png"/>
</td>
<td *ngIf="isActive === i">
<input type="text" [(ngModel)]="set.note" name="value" class="form-control" />
</td>
i
是索引来自ngFor
clickerTrue(set, index) {
this.isActive = this.isActive === index ? null : index;
}
isActive
变量第一个值为假。
解决方案
如果您使用的是 ngFor,为什么要传递对象?
<button *ngFor="let item of items" (click)="toggleActive(item)">click me</button>
toggleActive(item) {
item.active = !item.active;
}
推荐阅读
- angular - Show list depending on search results angular
- java - Java:操作数字中的位
- java - Java-Output all the columns and rows of a ResultSet
- html - 如何在 servlet 页面中的 java 代码之前执行 HTML 表单?或者如何安排响应打印机内的html标签和标签?
- r - 错误 r:简单回归中的无效下标类型“闭包”
- java - 我使用 xpath 找到了注册按钮,但它显示了 2 个匹配的节点。如何唯一标识注册按钮
- ios - 使用委托和协议我无法访问 UIButton 内的功能
- jquery - jquery $.post 动作调用了 2 次
- laravel - 如何使用 Laravel 和 Mockery 测试商店功能
- javascript - 如果使用 javascript 检查了复选框,则尝试隐藏引导模式