Variables between cotroller

.controller(‘LoginCtrl’, function($scope,$state,$http,$ionicPopup) {
$scope.loginn = function(){
var usuario = this.usuario; // asi se revise valores de html
var contrasena = this.contrasena;
$http.get(‘http://localhost:8000/exonerados/loginapp/’+usuario+’/’+contrasena+’’)
.success(function (response)
{
var valor = parseInt(response);
if(valor===1){
$ionicPopup.alert({
title: ‘Bienvenido’,
template: usuario
});
$state.go(‘app.sistemas’);
}else{
$ionicPopup.alert({
title: ‘Error’,
template: ‘Datos incorrectos’
});
$state.go(‘inicio’);
}

    });
   
}

})

.controller(‘SistemasCtrl’, function($scope, $stateParams) {

})

Good day, I need to be able to use the user variable throughout the application, is there a way to achieve this?

You can read about creating service

just go with the localstorage its may help you

Hi! Look, you have some options to variables between controller, some bad choices, but…
you can:

  • Create services
  • Pass with $broadcast, $on,
  • $window, window
  • $rootScope
1 Like