Angular 为按钮在角度方向上分配功能

Angular 为按钮在角度方向上分配功能,angular,Angular,我在一家公司工作。我的问题是,当按钮类型为“保存”时,意味着它必须执行某些功能;如果按钮类型为“更新”时,则意味着它必须执行某些功能 <button mat-flat-button color="primary" (click)="Editappaware info(drawer)" > {{button type}} </button> 试着这样做: 试着这样做: {{button type}请粘贴问题中的所有相关信息。{{button type}请粘贴问题中的

我在一家公司工作。我的问题是,当按钮类型为“保存”时,意味着它必须执行某些功能;如果按钮类型为“更新”时,则意味着它必须执行某些功能

<button mat-flat-button color="primary" (click)="Editappaware info(drawer)" > 
  {{button type}}
</button>
试着这样做:

试着这样做:


{{button type}请粘贴问题中的所有相关信息。{{button type}请粘贴问题中的所有相关信息。欢迎。如果这个答案有帮助,请接受。不客气。如果有帮助,请接受这个答案。
<button mat-flat-button color="primary" (click)="buttonType == 'save' ? save() : update()">{{buttonType}}</button>
<button mat-flat-button color="primary" (click)="onAction( buttonType )" >{{buttonType}}</button>
onAction( type: 'save' | 'update'){
  type ==='save' ? create() : update();
}