title: angularjs serialize form data
body: <p>i wish to serialize the form data in angularjs. following is the controller code:</p>
  
  <pre><code>   function SearchCtrl($scope, $element, $http) {
          $scope.url = 'php/search.php';
          $scope.submit = function() {
              var elem = angular.element($element);
              //var dt = $(elem.parent()).serialize();
              console.log($(elem.parent()).serialize());
              $http({
                  method: 'POST',
                  url: $scope.url,
                  data: 'first=hgf&amp;last=ghfgh',
                  headers: {'Content-Type': 'application/x-www-form-urlencoded'}
              }).success(function(data, status) {
                  $scope.status = status;
                  $scope.data = data;
                  $scope.result = data; // Show result from server in our &lt;pre&gt;&lt;/pre&gt; element
                  //var elem = angular.element(e.srcElement);
                  //alert($(elem.parent()).serialize());
              }).error(function(data, status) {
                  $scope.data = data || "Request failed";
                  $scope.status = status;
              });
              return false;
          };
  }
  </code></pre>
  
  <p><strong>edited:</strong></p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html ng-app&gt;
  &lt;head&gt;
  &lt;title&gt;Search form with AngualrJS&lt;/title&gt;
          &lt;script src="../angular-1.0.1.min.js"&gt;&lt;/script&gt;
          &lt;script src="http://code.jquery.com/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script src="js/search.js"&gt;&lt;/script&gt;
  
  
  
  &lt;/head&gt;
  &lt;body&gt;
          &lt;div&gt;
          &lt;form ng-controller="SearchCtrl" ng-submit="submit()"&gt;
              &lt;label&gt;Search:&lt;/label&gt;
              &lt;input type="text" ng-model="keywords" placeholder="enter name..."&gt;
              &lt;input type="text" ng-model="desc" placeholder="enter description..."&gt;
              &lt;button type="submit"&gt;Search&lt;/button&gt;
              &lt;p&gt;Try for example: "php" or "angularjs" or "asdfg"&lt;/p&gt;
          &lt;/form&gt;
  &lt;pre ng-model="result"&gt;
  {{result}}
  &lt;/pre&gt;
     &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>but nothing gets printed on the console. where am i going wrong?</p>