Reputation:
For example, i have this url: http://local.com/
. When i called function in my SearchController
i want set text=searchtext
and get url like this:
http://local.com/?text=searchtext
.
How i can do it? I tried $location.search('text', 'value');
but got this url:
http://local.com/#?text=searchtext
$scope.searchTracks = function() {
Search.search.get($scope.params, function(data) {
/** Set params in query string */
$location.search('text', $scope.text);
$location.search('sorted', $scope.sorted);
});
}
Upvotes: 1
Views: 2470
Reputation: 49873
You also need to specify the path :
$location
.path('/path/to/new/url')
.search({
'text': $scope.text,
'sorted': $scope.sorted
});
And the final url will be something like:
http://localhost/path/to/new/url?text={{$scope.text}}&sorted={{$scope.sorted}}
Another way is to set them manually:
$location.url('/path/to/new/url?text' + $scope.text + '&sorted=' + $scope.sorted);
Upvotes: 1