title: Angular.js What is the best way to determine which button caused submit?
body: <p>I have two buttons on a simple login form in a dropdown on a header bar that is outside of the view/content part of my single page app. There are two buttons on the form:</p>
  
  <p><strong>EDIT:</strong> both buttons need to submit the form, but I have two different outcomes; one does new member sign-up, the other login existing members. I do not want to handle this on multiple partials. </p>
  
  <p>
        
          
            
              
              
              
            
            My Website<br>
          </p>
  
  <pre><code>    &lt;div class="collapse navbar-collapse"&gt;
        &lt;ul class="nav navbar-nav navbar-right"&gt;
          &lt;li class="active"&gt;
            &lt;a href="#/home"&gt;Home&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="divider-vertical"&gt;&lt;/li&gt;
          &lt;li&gt;
            &lt;div class="btn-group btn-group-xs navbar-btn btn-pad"&gt;
              &lt;a href="#" class="btn navbar-btn btn-default"&gt;NL&lt;/a&gt;
              &lt;a href="#" class="btn navbar-btn btn-default"&gt;FR&lt;/a&gt;
              &lt;a href="#" class="btn navbar-btn btn-default"&gt;EN&lt;/a&gt;
            &lt;/div&gt;
          &lt;/li&gt;
          &lt;li class="divider-vertical"&gt;&lt;/li&gt;
          &lt;!-- Begin Login Section --&gt;
          &lt;li class="dropdown"&gt;
            &lt;a class="dropdown-toggle" href="#" data-toggle="dropdown"&gt;Signup/Login &lt;strong class="caret"&gt;&lt;/strong&gt;&lt;/a&gt;
            &lt;div class="dropdown-menu"&gt;
              &lt;div class="accountForm"&gt;
                &lt;!--form action="#" method="post" role="form"--&gt;
                &lt;form name="loginForm" ng-submit="login()" ng-controller="homeController"&gt;
                  &lt;div class="form-group"&gt;
                    &lt;label class="control-label" for="username"&gt;Username&lt;/label&gt;
                    &lt;input type="text" ng-model="credentials.username" name="username" class="form-control input-sm" placeholder="username" required/&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                    &lt;label class="control-label" for="password"&gt;Password&lt;/label&gt;
                    &lt;input type="password" ng-model="credentials.password" name="password" class="form-control input-sm" placeholder="password"  required/&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                    &lt;label class="control-label" for="remember"&gt;
                      &lt;input type="checkbox" class"form-control" name="remember" value="1"/&gt;Remember me&lt;/label&gt;
                  &lt;/div&gt; 
                  &lt;div class="form-group btn-group-justified"&gt;
                    &lt;div class="btn-group"&gt;
                      &lt;button button-id="join" type="submit" class="btn btn-default"&gt;New? Join us&lt;/button&gt;
                      &lt;input type="hidden" class="btn" /&gt;
                    &lt;/div&gt;
                    &lt;div class="btn-group inline"&gt;
                      &lt;input type="hidden" class="btn" /&gt;
                      &lt;button button-id="login" type="submit" class="btn btn-primary active"&gt;Log in&lt;/button&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;   
                &lt;/form&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/li&gt;
          &lt;!-- End Login Section --&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
      &lt;!--/.nav-collapse --&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="page" ng-view&gt;
  </code></pre>
  
  <p>The first button is intended to send the user to the login process (if they are already registered) and the second button is for new users to register.</p>
  
  <p>The problem I have is that if I use the <code>&lt;form ng-submit="myFunction()"&gt;</code> directive, I haven't yet found a way to determine the button that was pressed.</p>
  
  <p>I can alternatively create my own directive, where I can determine the button that was pressed, but this seems to be a lot of coding effort by comparison, and is this really the Angular way?</p>
  
  <p>app.directive('buttonId', function() {
          return {
              restrict: "A",
              link: function(scope, element, attributes) {</p>
  
  <pre><code>            element.bind("click", function(){
                  // when attributes.buttonId = 'join' 
  //call the create script
  
                  // when attributes.buttonId = 'login' 
  //call the authenticate script
  
              });         
          }
      }
  });
  </code></pre>
  
  <p>So my question is simply using <code>ng-submit="myfunction()"</code>can i determine which button was pressed?</p>