[英]how to show spinner for selected table row in angular 8
I have a list of videos coming from api.我有一份来自 api 的视频列表。 when play icon of a particular video from table is clicked a modal box opens.
当单击表格中特定视频的播放图标时,会打开一个模式框。 I want that when we submit this modal box a spinner starts rotating until it get response from server.
我希望当我们提交这个模态框时,一个微调器开始旋转,直到它得到服务器的响应。
my component.html我的组件.html
<table class="table table-striped tabs">
<thead>
<tr>
<th>S. No.</th>
<th>Id</th>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<tr
*ngFor="
let hero of getCamListPay | paginate: config;
let x = index
"
>
<td>{{ x + 1 }}</td>
<td>{{ hero.Id }}</td>
<td>{{ hero.Name }}</td>
<td>
<a>
<i (click)="startCameraByForm(hero.Id, temp)"
[ngClass]="[loadIcon ? 'fa fa-play' : 'fa fa-spinner fa-spin']"
aria-hidden="true" >
</i>
</a>
</td>
</tr>
</tbody>
</table>
here is my component.ts file这是我的 component.ts 文件
startCameraByForm(cameraId: number, temp: TemplateRef<any>) {
this.modalRef = this.modalService.show(temp);
this.camIdField = cameraId;
}
onSubmit(camInfo): void {
this.isSubmitted = true;
if (this.camInfoForm.valid) {
this.hideModalBox();
this.loadIcon = false;
this.camServ.dummyService(this.camInfoForm).subscribe((res: any)=>{
console.log(res);
this.loadIcon = true;
})
}
}
Try this:尝试这个:
Change loadIcon
to be boolean[this.getCamListPay.length]
.将
loadIcon
更改为boolean[this.getCamListPay.length]
。 Then in markup (click)="startCameraByForm(hero.Id, temp, x)
and [ngClass]="[loadIcon[x]? 'fa fa-play': 'fa fa-spinner fa-spin']"
然后在标记
(click)="startCameraByForm(hero.Id, temp, x)
和[ngClass]="[loadIcon[x]? 'fa fa-play': 'fa fa-spinner fa-spin']"
[ngClass]="[loadIcon[x]? 'fa fa-play': 'fa fa-spinner fa-spin']"
. And in code: [ngClass]="[loadIcon[x]? 'fa fa-play': 'fa fa-spinner fa-spin']"
。在代码中:
startCameraByForm(cameraId: number, temp: TemplateRef<any>, x: number) {
this.modalRef = this.modalService.show(temp);
this.camIdField = cameraId;
this.selectedIndex = x;
}
onSubmit(camInfo): void {
this.isSubmitted = true;
if (this.camInfoForm.valid) {
this.hideModalBox();
this.loadIcon[this.selectedIndex] = false;
this.camServ.dummyService(this.camInfoForm).subscribe((res: any)=>{
console.log(res);
this.loadIcon[this.selectedIndex] = true;
})
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.