title: angularjs access form element inside ngsubmit function
body: <p>how can i get access to the form element attributes inside the function that get called on ng-submit ?</p>
  
  <pre><code>.controller('loginCtrl', function ($scope, $rootScope, $location, $window, session,$http) {
  
      $scope.error = null;
      console.log($scope);
  
      $scope.attempt = function (url) {
          //URL get passed.. but i want to fetch it from the form action attribute
          var data = {username:$scope.info.u,password:$scope.info.u};
  
          $http.post(ul, data).success(function(response) {
              $scope.error = "welcome";
              $rootScope.currentUser = data;
              session.set('siUser', data);
              $location.path('/dash');
          }).error(function(reason) {
              $scope.error = "failed try again" + $scope.info.p + ' ' + $scope.info.u;
          });
      };
  })
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;form role="form" ng-submit="attempt('&lt;?=base_url('auth/login');?&gt;')" method="post"&gt;
                      &lt;fieldset&gt;
                          &lt;div class="form-group"&gt;
                              &lt;input type="text" ng-model="info.u" placeholder="Username" class="form-control" ng-min-length="4" required /&gt;
                              &lt;p ng-show="info.u.$invalid" class="help-block"&gt;You username is required.&lt;/p&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                              &lt;input type="password" name="password" ng-model="info.p" placeholder="Password" class="form-control" /&gt;
                              &lt;p ng-show="info.p.$invalid" class="help-block"&gt;password is required.&lt;/p&gt;
                          &lt;/div&gt;
                          &lt;button ng-disabled="loginForm.$invalid" class="btn btn-lg btn-success btn-block" type="submit"&gt;Login&lt;/button&gt;
                      &lt;/fieldset&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>currently what i'm doing is passing it to the function. but is there a cleaner way to access the element from inside controller function?</p>