Reputation: 68
I tried to integrated sails.js as a route controller and api management, using angular.js as frontend, but I found the problem when using angular to modify URL
For an example /
Original URL : http://localhost
after modify by $location.search({'lang':destLanguage});
Modified URL : http://localhost#?lang=fr
Then I am using $window.location.reload(); to reload the page to send the GET parameter to the sails controller, but when I debug at the page controller, I found that sails couldn't read the parameter from request.
req.param('lang') == undefined
I am not sure how to solve this issue. I tried to solve these issue for a whole few days.
Thanks,
Upvotes: 1
Views: 152
Reputation: 5979
After the hash are not query params for the server. It would need to be before the hash, or remove the hash all together.
instead just create function to incorporate into your app
var updateLang = function(lang){
window.location = 'http://localhost?lang=' + lang
}
The rest of the answer depends on if your angular is setup to use html5Mode = true. If so, then you can use angular's $location.search() to retrieve your values. If not, then you will need to find a plain javascript to grab that value either on page load or when / where you need it.
Upvotes: 2