title: Angular : send user activity to server
body: <p>I would like to send user activities to server, especially which button the user clicked.</p>
  
  <p>What I would like to do is same with <a href="https://stackoverflow.com/questions/45767704/angularjs-send-user-activity-to-server">this post</a> as I asked before. The post is AngularJS, what I would like to ask is Angular ( I am using Angular8 ).</p>
  
  <p>I know I can do it like this.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;button (click)="pressA()"&gt;A&lt;/buttion&gt;
  &lt;button (click)="pressB()"&gt;B&lt;/buttion&gt;
  </code></pre>
  
  <p>Typescript:</p>
  
  <pre><code>@Component({
    templateUrl:"my.html"
  })
  export class MyApp {
  
    pressA() {
      sendServer("A");
      // Do other things for button A
    }
  
    pressB() {
      sendServer("B");
      // Do other things for button B
    }
  
  
    sendServer(val: string) {
      // POST val to https://(mydomain)/(path)
    }  
  }
  </code></pre>
  
  <p>But this way require me to insert sendServer to all click event. It is bothersome. Can I do this more efficient way?</p>