-1

I want to change the text of a button when it‘s cklicked and change it back when it‘s clicked again. How can I do that?

I tried something like that. But I dont know who I can adress to the text because there is no property like eg with color for ion-buttons

Html

<button (click)="changeText()" ion-button>Hello</button> 

TS

  public text: string = 'hello';

constructor

 public changeText(): void {
      if(this.text === 'hello') { 
        this.text = 'rank'
      } else {
        this.text = 'hello'
      }
    }
CMC
  • 79
  • 1
  • 3
  • 11

1 Answers1

4

You can use interpolation, then your button would look like this:

<button (click)="changeText()" ion-button>{{text}}</button> 
fawee
  • 395
  • 3
  • 13