Convert $.param in angularjs Convert $.param in angularjs angularjs angularjs

Convert $.param in angularjs


There's a built-in serializer in angular which mimics $.param():$httpParamSerializerJQLike


If you are trying to create serialized representation of data like $.param() does,

function serializeData( data ) {     // If this is not an object, defer to native stringification.    if ( ! angular.isObject( data ) ) {         return( ( data == null ) ? "" : data.toString() );     }    var buffer = [];    // Serialize each key in the object.    for ( var name in data ) {         if ( ! data.hasOwnProperty( name ) ) {             continue;         }        var value = data[ name ];        buffer.push(            encodeURIComponent( name ) + "=" + encodeURIComponent( ( value == null ) ? "" : value )        );     }    // Serialize the buffer and clean it up for transportation.    var source = buffer.join( "&" ).replace( /%20/g, "+" );     return( source ); }

and use this for your data serialization


AngularJs has jquery lite on its core so you can use angular.element.param() instead of $.param()