Passing Params from one controller to another


hey everyone
I need to make an ionic app that login through authentication http web service and I finished it and it’s working , but I have t pass to the url the following (username , password , auth)
auth is either student or staff
so i need to use the user object in other places in the app (other controllers ) but i don’t know how to get the parameters again , since i can’t get it from the service because i have to pass username , password and auth to get the user object
what to do

this is my userService Code
This message was deleted

mgisApp.factory('userService', function($http) {
  var users = {};

  return {
    getUser: function(username,password,auth){

      var servicebase = "";
      return $http.get(servicebase + "username="+username+"&password=" + password + "&auth="+auth).then(function(response){
        users = response;
        return users;
    getSingleUser: function(uid){

      return users[uid];


and this is the controller that works well with it which is the login controller

mgisApp.controller('LoginCtrl', function($scope,$state, $stateParams, userService, $ionicPopup) {

  // An alert dialog
  $scope.showAlert = function() {
    var alertPopup = $ionicPopup.alert({
      title: 'Error',
      template: 'invalid username or password'
    alertPopup.then(function(res) {
      console.log('you have accepted the alert');

    $scope.onSignInClicked = function(username,password,auth) {

      var inputUsername=username,

      console.log("Input Fields:"+ inputUsername + "- "+inputPassword+ "- "+inputAuth);
      // var user = userService.getUser(inputUsername,inputPassword,inputAuth);
        console.log("Service Fields:"+ serviceUsername + "- "+servicePassword+ "- "+serviceAuth);
        console.log("Service ID: "+;
        if (inputUsername == serviceUsername && inputPassword == servicePassword && inputAuth == serviceAuth) {
          localStorage.setItem('loggedIn', true);
        } else {


I need to get a list of messages that this particular user have

mgisApp.factory('Chats', function($http) {
  var chats = {};

  return {
    getChats: function(auth,id,api_token){
      var servicebase = "";
      return $http.get(servicebase + "auth="+auth+"&id=" + id + "&api_token="+api_token).then(function(response){
       chats = response;
       return chats;

` and the controller I am trying to work on , trying to get the auth , id , api_token is right here

 mgisApp.controller('DashCtrl', function($scope ,userService) {

//cant access the user because i can't have the parameters, username , password , auth


Try using $rootScope, then you can pass it to another controller , or if you are going to keep the user signed in, use localStorage.
But, why do you want to store the password?


Thanks @vahidvdn for your answer

I am already using local storage ,I used it to keep the user logged in ,but I don’t need to store the password or use it in any of the other controllers,all what i need to use is the id and auth and api token from the userService , because i want to integrate with messages service , the messages api take in the url ,

and those (id , api_token , auth ) are in the userService , and i need to get the current one