javascript - 如何在Angular中更新表格的单个单元格?
问题描述
我正在尝试更新该单列悬停时的表格单元格,而不是相同内容的所有列。这是更新我的 ngswitchCase 待处理的所有列,但我只希望该特定行的表中的单个单元格获取更新/呈现不同的按钮。
<div [ngSwitch]="rowData['dataFromJson']">
<div *ngSwitchCase="'pending'">
<div *ngIf="condition"; then thenBlock; else elseBlock">
</div>
<ng-template #thenBlock>
<button (mouseover)="condition=!condition">A</button>
</ng-template>
<ng-template #elseBlock>
<button (mouseleave)="condition=!condition">B</button>
</ng-template>
</div>
解决方案
假设我们看到的是一个更大模板的片段,而不是组件的整个模板:如果组件condition
之间共享一个属性,那么对于每个人来说它当然是真或假。制作condition
一个数组(每行一个条目)。
或者,将上述内容作为一个单独的组件,condition
然后将其包含在其范围内。
推荐阅读
- tcl - 从字符串中获取一个字段,将其存储在一个变量中,然后进行比较
- jwt - 通过服务帐户通过 nodemailer 发送邮件时的身份验证问题
- mysql - 2 count(*)+group by+have+join
- c# - 将传入的 Excel 类型更改为字符串
- git - Jenkins 在尝试从 Bitbucket 结帐时删除了工作区
- session - Laravel + Nginx。会话被随机访问
- bash - 如何从带有保留空格的管道(|)分隔文件中读取字段
- json - 如何连接来自不同 nosql 集合的两个数组?
- printing - 根据列值在每一页上打印标题 - 数据表
- parsing - 有没有办法在宏中实现可选表达式?