单击我尝试过的按钮后,我想更改所选行的背景颜色,但更改所有行的颜色。这是一个类似的代码。
HTML
<tr *ngFor="let data of (datas$ | async) | filter:authService.filter | paginate: config | orderBy: key : reverse" [ngClass]="{'data-selected':isSelected}">
<td>{{data.id}}</td>
<td>{{data.text}}</td>
<td>
<a class="mr-3" (click)="delete(data.id)"><i class="fa fa-remove"></i>
Remove
</a>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
TS
delete(postId) {
this.isSelected=true;
const ans = confirm('TEXT TEXT '+dataid);
if (ans) {
this.dataService.deleteData(postId).subscribe((data) => {
if(data) {
this.showSuccessDelete();
} else {
this.showError();
}
this.isSelected=false;
this.loadDatas();
});
}
}
Run Code Online (Sandbox Code Playgroud)
CSS
.data-selected{
background-color: #e9eaea;
}
Run Code Online (Sandbox Code Playgroud)
非常感谢