I have a system with Angular and Java.
In the initial route I read the url parameters (some user information, such as code, etc.) and saved in $ rootScope to access throughout the application.
If I access directly through the browser, it works accordingly, the example of the link is this:
But I have another system that generates these links and e-mail some recipients, and they access from the email, with these parameters embedded in the url.
In these cases, Angular loads the main link, however it ends up clearing all the parameters, leaving the url just like this:
To read the parameters, I'm using $ location.search () with the Angular.
Edit:
I retrieve the parameters in the "module.run ()" from the application's Angle.
function run($rootScope, $location) {
var data = $location.search();
if (data) {
$rootScope.parametro1= data.parametro1;
$rootScope.parametro2= data.parametro2;
}
}
Angle Routes
function config($stateProvider, $urlRouterProvider) {
//Route Default
$urlRouterProvider.otherwise('/login');
//Routes
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'templates/login.html',
controller: 'AuthenticationCtrl',
controllerAs: 'vm'
})
}
Login Controller
function AuthenticationCtrl($state, $rootScope, $location) {
var vm = this;
vm.init = init;
init();
function init() {
//Faço o parse, pois esse parâmetro é sempre inteiro..
vm.parametro1 = parseInt($rootScope.parametro1);
}
}
Does anyone know why this behavior?
How do I fix this?