I have an icon "fa-duotone fa-rotate-right", and I want when changing "loading = true", the class "fa-spin" is added, everything works ok, but when it becomes "false" it does not stop, I’m a beginner in Angular, don’t discuss much, maybe you know how you can decide or tell me. Thanks
Html
<button mat-fab color="primary" class="float-end" (click)="load()">
<mat-icon class="fa-duotone fa-rotate-right" [ngClass]="loading ? 'fa-spin' : ''"></mat-icon>
</button>
Typescript
load(): void {
this.loading = true;
this.productsService.getProducts().subscribe(
(response: any) => {
this.dataSource = new MatTableDataSource(response.products);
this.dataSource.paginator = this.paginator;
this.loading = false;
this.selection.clear();
},
error => {
this.alertService.error('Server error in Getting Products');
}
);
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/lGtBC26
Comments
Post a Comment