切换时,如何在垫按钮更改文本

<form class="example-form" style="text-align: center;" [formGroup]="loginForm" (ngSubmit)="buttonClicked()">
  <mat-card [@myAwesomeAnimation]='state' (mouseenter)="animateMe()" (mouseleave)="animateMe()" style="padding: 2vh">
      <input type="text" class="mainInput" style="font-size: 18px;" matInput autofocus shouldLabelFloat="false" placeholder="Insert Your URL Here" autocomplete="off">
  </mat-card>
  <br>
  <button mat-raised-button color="accent"></button>

</form>

最佳答案

你可以有一个切换变量?

然后按如下使用

<button (click)="doToggle()">{{toggle ? 'Toggled':'Not Toggled'}}</button>

然后在TS
toggle:boolean = false;

doToggle():void{
   this.toggle = !this.toggle;
   // Do some other stuff needed
 }

请参阅fiddle

关于angular - Angular ,切换时如何在<mat-button>中更改文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47828102/

10-12 12:22
查看更多