there are many implementations of the loading indicator while an xhr request is in progress. Some do full page overlay, some display a message in a designated spot on the screen and so on...
I'd like to create a compact solution that I can use it over and over again across multiple projects with 0 footprint and min additional work. For that goal, I decided to implement the loading indicator right within the button being clicked on.
For example, if the button is titled as "SAVE", upon a click on this button, I'd like the button to show a spinner icon next to the word "SAVE" while the following things to happen:
1) button gets immediately disabled so a new click over it is ignored.
2) a loading indicator ( a spinning gif ) starts appearing right next to left of the word "SAVE" and this spinner continues to spin until XHR comes back with a response
3) when XHR responds, button gets enabled again
Since the spinner takes place within the button, the footprint is 0. Since the spinner takes place within the button, there is no overhead of creating special <div>
's in the HTML..
Could someone share with me the topics I need to learn in order to pull this off?
I know about XHR part and the angular's (click) event stuff.
Where I need help is the managing of that spinner's appearing and disappearing and that making that button active or inactive...
I know the solution is somewhere around ngStyle, ngClass, mat-icons, and the [disabled] directive of the button but cannot wrap my mind around it.