Various loading indicators are used during an xhr request, such as full-page overlays or messages displayed in specific spots on the screen.
I aim to develop a streamlined solution that can be easily implemented across multiple projects with minimal additional work. To achieve this, I have chosen to embed the loading indicator directly within the button being clicked on.
For instance, when clicking on a button labeled "SAVE", I want the button to display a spinner icon next to the word "SAVE" while taking the following actions:
1) Immediately disable the button to prevent further clicks.
2) Show a spinning gif loader beside the word "SAVE", continuing until the XHR response is received.
3) Enable the button again once the XHR response is received.
By placing the spinner within the button, there is no additional footprint or need for extra <div>
elements in the HTML.
Could someone provide guidance on the necessary topics to learn for implementing this?
I am familiar with XHR and Angular's (click) event handling. However, I require assistance in managing the appearance and disappearance of the spinner, as well as enabling/disabling the button.
I believe the solution involves techniques like ngStyle, ngClass, mat-icons, and the [disabled] directive for the button, but I need help putting it all together.