/course-home#/search?q=my%20lab%20%26%20mastering&%20kamal&ref=%2Ftab%2Factive
$scope.keyword = $location.search().q;
In my angular app when I search for "my lab & mastering" $location.search().q returns only "my lab" and does not return full string. after the "&" it does not work properly. What is the best way to get query string from above URL ?
create a $scope
which is set to an array of symbols. Include in this array the & symbol and add it to your data.
I think that is because it has the url encoding of %26 . Check out the W3C cheat sheet about URL encoding to see how exactly to reference them:
Found the issue, and the issue was URL encoding not done properly.
$location.url('/search?q=' + searchText + '&ref=' + $location.$$path);
To fix the issue need to encode the searchText variable
$location.url('/search?q=' + encodeURIComponent(searchText) + '&ref=' + $location.$$path);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.