I am currently working on a solution in Angular 12 to disable a button (and show a spinner) when it is clicked, until the API responds.
To achieve this, I plan to follow a similar approach to the angular-material button implementation. Essentially, I want to use an attribute selector for a custom button-component and apply it to the button element.
The simple code snippet below functions as expected, however, when adding the 'app-button-loading' alongside the mat-raised-button, the application crashes with an NG0300 error: Error: NG0300: Multiple components match node with tagname button.
<button app-button-loading color="primary"> Click me! </button>
Please note that if app-button-loading were a Directive, it would work perfectly fine.
I also tried to specify the material selectors, but it doesn't seem to resolve the issue:
selector: "button[mat-button][app-button-loading], button[mat-raised-button][app-button-loading]"
I found a satisfactory solution using a Directive instead of a Component with an attribute selector (dynamically creating a mat-spinner component), and it works well. However, I wish to add some styles without including them in the global styles.scss.
TL;DR; Is it feasible to include a Component with an attribute selector along with the material selector mat-raised-button (or any other)? Or does Angular not permit the usage of Components in this manner?
<button mat-raised-button app-button-loading color="primary"> Click me! </button>
Additionally, I have developed a simplified demo on stackblitz which might be helpful.