Angular,如何在切换时更改<mat-button>中的文本

Gia*_*rco 1 angular-material angular

我怎样才能改变文本垫子按钮,当我切换了吗?

<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>
Run Code Online (Sandbox Code Playgroud)

Tin*_*son 6

你可以有一个切换变量吗?

然后按如下方式使用它

<button (click)="doToggle()">{{toggle ? 'Toggled':'Not Toggled'}}</button>
Run Code Online (Sandbox Code Playgroud)

然后在TS

toggle:boolean = false;

doToggle():void{
   this.toggle = !this.toggle;
   // Do some other stuff needed
 }
Run Code Online (Sandbox Code Playgroud)

请看小提琴