Currently I am toying with the AngularJS framework. I\'m using the $route service for deep linking into my single-page application.
Now I would like to navigate inside m
Starting from v1.4 you can use $httpParamSerializer for that:
angular.module('util').factory('urlBuilder', function($httpParamSerializer) {
function buildUrl(url, params) {
var serializedParams = $httpParamSerializer(params);
if (serializedParams.length > 0) {
url += ((url.indexOf('?') === -1) ? '?' : '&') + serializedParams;
}
return url;
}
return buildUrl;
});
Usage:
To produce http://url?param1=value1¶m2=value2_1¶m2=value2_2
call it with:
urlBuilder('http://url', { param1: 'value1', param2: ['value2_1', 'value2_2'] });