Congratulations!
The above decision from
Balkishan Dhaker will not let you create the bindings and styles you want.
I recommend you take a slightly different approach to designing such components.
Component.ts
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
@Component({
selector: 'help-component',
templateUrl: './help-page.component.html',
styleUrl: './help-page.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
})
export class HelpPageComponent {
@Input() public type?: AllowedInputTypes = "flat"
constructor() { }
}
type AllowedInputTypes = 'basic' | 'flat' | 'raised'
component.html
<ng-container [ngSwitch]="type">
<!-- Raised -->
<ng-container *ngSwitchCase="'raised'">
<button mat-raised-button>
<ng-container [ngTemplateOutlet]="content"></ng-container>
</button>
</ng-container>
<!-- / Raised / -->
<!-- / Flat / -->
<ng-container *ngSwitchCase="'flat'">
<button mat-flat-button>
<ng-container [ngTemplateOutlet]="content"></ng-container>
</button>
</ng-container>
<!-- Flat -->
<!-- Basic -->
<ng-container *ngSwitchCase="'basic'">
<button mat-button>
<ng-container [ngTemplateOutlet]="content"></ng-container>
</button>
</ng-container>
<!-- / Basic / -->
</ng-container>
<ng-template #content>
<ng-content></ng-content>
</ng-template>
You need to call the component as follows:
other.component.html
<!-- Default -->
<help-component>MyFlatButton</help-component>
<!-- / Default / -->
<help-component [type]="'basic'">MyBasicButton</help-component>
<help-component [type]="'flat'">MyFlatButton</help-component>
<help-component [type]="'raised'">MyRaisedButton</help-component>
Such a solution will allow you to centralize your button settings and avoid other, redundant logic for mat-button rendering
[Stylization]
Use mixins to style mat components. see the documentation on the Angular material site.
usage example:
help-page.component.scss
@use '@angular/material' as mat;
:host {}
:host.custom-flat-style {
@include mat.button-overrides((protected-container-color: red));
}
Call a custom component using mixins:
<help-component [type]="'raised'" class="custom-flat-style">2344</help-component>