In my AngularJS application using RestAngular, I have the following controller method:
$scope.findFriend = function (name, type, limit) {
return FriendSearch.getList({
name: name,
type: type,
limit: limit
});
};
Sometimes, the type parameter may be empty, resulting in an invalid URL generated by Restangular:
http://host:port/rest/friends/search?limit=10&name=Peter&type=
The correct URL should omit the empty type parameter:
http://host:port/rest/friends/search?limit=10&name=Peter
While I can check the parameters before passing them, I'm interested to know if there's a more elegant solution to handle this situation.