title: Detect which submit button is used in an Angular2 RC5 Reactive Form
body: <p>I'm creating a prove of concept to see if angular2 can be used in our firm.  I've gotten quite far sofar but now I'm a bit stuck.  I'm consuming a REST resource and like to Get, Post, Put, and Delete by using a form.  This is the form I currently have</p>
  
  <pre><code>&lt;section&gt;
      &lt;form [formGroup]="form" (submit)="submit($event)"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;&lt;label&gt;Id:&lt;/label&gt;&lt;/td&gt;
                  &lt;td colspan="2"&gt;&lt;input type="text" formControlName="id"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;&lt;label&gt;Message:&lt;/label&gt;&lt;/td&gt;
                  &lt;td colspan="2"&gt;&lt;input type="text" formControlName="message" size="50"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;button id="getButton" type="submit"&gt;GET&lt;/button&gt;&amp;nbsp;&lt;input type="text" formControlName="getId"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;button id="postButton" type="submit"&gt;POST&lt;/button&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;button id="putButton" type="submit"&gt;PUT&lt;/button&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;button id="deleteButton" type="submit"&gt;DELETE&lt;/button&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>The submit gets registered and sent back to my @Component</p>
  
  <pre><code>import {Component, OnInit} from "@angular/core";
  import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
  import {HelloWorld} from "../../restclient/helloworld/helloworld.model";
  import {HelloWorldClient} from "../../restclient/helloworld/helloworld.client";
  
  @Component({
      selector: "helloworld-form",
      template: require('./helloworld-form.html')
  })
  export class HelloWorldForm implements OnInit{
      fb: FormBuilder;
      form: FormGroup;
      getId : number;
  
      constructor(fb: FormBuilder, private _helloWorldClient: HelloWorldClient) {
          this.fb = fb;
          this.form = fb.group({
              "id": '',
              "message": '',
              "getId": ''
          });
      }
  
      ngOnInit(): void {
          this.form.controls["getId"]
              .valueChanges.subscribe(value =&gt; {
                  this.getId = value;
          });
      }
  
      public setData(data : HelloWorld): void {
          this.form = this.fb.group({
              "id": data.id,
              "message": data.message,
              "getId": ''
          });
      }
  
      public getClicked() {
          this._helloWorldClient
              .GetSingle(this.getId)
              .subscribe((data:HelloWorld) =&gt; this.setData(data),
                  error =&gt; console.log(error),
                  () =&gt; console.log('Fetching single by id ' + this.getId + " completed"));
      }
  
      public submit(event) {
          event.preventDefault();
          console.log(event);
          var target = event.target || event.srcElement || event.currentTarget;
          console.log(target);
          var idAttr = target.attributes.id;
          console.log(idAttr);
          var value = idAttr.nodeValue;
          console.log(this.form);
      }
  }
  </code></pre>
  
  <p>Now what I like to do is somehow detect in the submit(event) method which submit button has been pressed.  I had hoped the event would hold that data, but instead it holds the form being submitted, with no clear way of finding the button being clicked.  What is the approved way in Angular2 to do this ?  I've been thinking on adding click events to each button and then saving in a variable on the component which button has been clicked, not sure that is the correct way though.</p>