Skip to content Skip to sidebar Skip to footer

Angularjs Serialize Form Data

i wish to serialize the form data in angularjs. following is the controller code: function SearchCtrl($scope, $element, $http) { $scope.url = 'php/search.php'; $

Solution 1:

From the doc:

For a form element's value to be included in the serialized string, the element must have a name attribute.

In your HTML inputs do not have names, hence serialize returns an empty string. Fix this with something like...

<inputtype="text" name="keywords" ng-model="keywords" placeholder="enter name...">
<inputtype="text" name="desc" ng-model="desc" placeholder="enter description...">

And, btw, you don't have to wrap Angular $element into jQuery function: $element.serialize() would work ok.

Demo.

Post a Comment for "Angularjs Serialize Form Data"