Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
fix(material): account for an Angular bug of using template expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Klemen Oslaj committed Oct 14, 2020
1 parent c1bd29c commit 44561a9
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions projects/material/src/lib/action-mat-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,30 @@ import { isMenuItem } from './common';
import { actionMatButtonTemplate } from './action-mat-button.template';
import { ICON_TYPE, ACTION_ICON_TYPE_TOKEN } from './action-icon-type-token';

export const enum ButtonType {
Button,
ButtonMenu,
MenuItem,
MenuItemMenu,
}
export const ButtonType = <const>{
Button: 0,
ButtonMenu: 1,
MenuItem: 2,
MenuItemMenu: 3,
};

@Component({
selector: 'action-mat-button',
template: `
<ng-container *ngIf="_action && _action.visible$ | async" [ngSwitch]="_getButtonType(_action!)">
<button *ngSwitchCase="${ButtonType.Button}" mat-button [actionMatButton]="_action">
<button *ngSwitchCase="ButtonType.Button" mat-button [actionMatButton]="_action">
<ng-container *ngTemplateOutlet="content; context: { $implicit: _action }"></ng-container>
</button>
<button *ngSwitchCase="${ButtonType.ButtonMenu}" mat-button [actionMatButton]="_action" [matMenuTriggerFor]="_forMatMenu">
<button *ngSwitchCase="ButtonType.ButtonMenu" mat-button [actionMatButton]="_action" [matMenuTriggerFor]="_forMatMenu">
<ng-container *ngTemplateOutlet="content; context: { $implicit: _action }"></ng-container>
</button>
<button *ngSwitchCase="${ButtonType.MenuItem}" mat-menu-item [actionMatButton]="_action">
<button *ngSwitchCase="ButtonType.MenuItem" mat-menu-item [actionMatButton]="_action">
<ng-container *ngTemplateOutlet="content; context: { $implicit: _action }"></ng-container>
</button>
<button *ngSwitchCase="${ButtonType.MenuItemMenu}" mat-menu-item [actionMatButton]="_action" [matMenuTriggerFor]="_forMatMenu">
<button *ngSwitchCase="ButtonType.MenuItemMenu" mat-menu-item [actionMatButton]="_action" [matMenuTriggerFor]="_forMatMenu">
<ng-container *ngTemplateOutlet="content; context: { $implicit: _action }"></ng-container>
</button>
</ng-container>
Expand Down Expand Up @@ -57,6 +60,8 @@ export class ActionMatButtonComponent implements ActionButtonComponentImpl, Focu
@HostBinding('class')
readonly _classname = 'action-mat-button';

ButtonType = ButtonType;

constructor(
@Inject(ACTION_ICON_TYPE_TOKEN)
readonly _iconType: ICON_TYPE,
Expand Down

0 comments on commit 44561a9

Please sign in to comment.