title: How to change the event at the press of a button in angular 6?
body: <p>everyone. 
  I just started to learn Angular 6 and I have a question. I need that when a button is pressed, not only does the text of the button change, but the event changes, which should occur when the button is pressed. For example, the first click on the button will add the component to the memory, and the second click on this button will delete.</p>
  
  <p>Here is my code from HTML:</p>
  
  <pre><code>&lt;button class="btn" (click)="toggleEvent()"&gt;
          {{addToMemory ? 'Add to memory' : 'Delete from memory'}}
  &lt;/button&gt;
  </code></pre>
  
  <p>From TS:</p>
  
  <pre><code>addToMemory: boolean = true;
  
  toggleEvent(): void {
   this.addToMemory = !this.addToMemory;
  }
  </code></pre>
  
  <p>I have a function that will add the film to memory and delete. </p>
  
  <pre><code>add() {}
  delete() {}
  </code></pre>
  
  <p>But I don’t understand how to switch a button by clicking between these functions. Please explain and help. Examples that I have found or do not work or it is not clear how to apply them.
  Sorry for my bad english.</p>