【发布时间】:2021-02-11 03:36:25
【问题描述】:
我在我的项目中使用 Angular Material。我想根据变量动态设置按钮类型。我尝试了类似以下的方法:
export class ButtonComponent {
type: 'simple' | 'raised' | 'stroked' | 'flat' | 'icon' | 'fab' | 'mini-fab' = 'simple";
}
在 HTML 中
<button [mat-button]="type === 'simple'" [mat-raised-button]="type === 'raised'">
Text goes here
</button>
但我收到以下错误:
无法绑定到“mat-button”,因为它不是“button”的已知属性
虽然我在 module.ts 中导入了 MatButtonModule
感谢您抽出宝贵时间,并提前感谢大家。
【问题讨论】:
标签: angular button angular-material