title: promise is not returning to defer in AngularJs
body: <p>Function is being executed but its not returning the userType value to defer. hence navigating to default page.</p>
  
  <blockquote>
    <p>I have two login type say manager admin, based on the response from UI page it should navigate to respective page,this is my requirement.
    I am even getting response from UI to angular controller but within promise its not fetching those value.
    Any help could be appreciated</p>
  </blockquote>
  
  <h2>StudentRepository.js</h2>
  
  <pre><code>angular.module('student').service('StudentRepository',['$http','$q','$rootScope', function(http, $q,rootScope){
      var user=[];
      this.loginCheck = function(id,password,userType){
          var testVar  = id + "," +password+","+userType;
          var defer = $q.defer(); 
          var studentPromise =  http.put('/Stud/login/',testVar);
          //in testVar also am getting all these values
          studentPromise.then(function(result){ 
           //within this function in result.data am getting null
              user = result.data;
              alert("the result is"+result.data);
              defer.resolve(user);
          });
          return defer.promise;
      };
      }]);
  </code></pre>
  
  <h2>logon.js</h2>
  
  <pre><code>angular.module('student').controller('LogonController', ['$http','$scope',
     'StudentRepository', '$stateParams', '$state','$rootScope',
      function(http,scope,StudentRepository,stateParams,state,rootScope){
  
      alert("we r in logon controller ");
      scope.loginCheck  = function(){
      //enter the input values,after submit
  
      alert("userType"+ scope.user.userType);
          StudentRepository.loginCheck(scope.user.id,scope.user.password,scope.user.userType)
      .then(function (response){
      rootScope.role=response;
      alert(" logon controller"+response);
  
      if(response == "manager")
      {
          scope.manager=response;
          alert("The user is manager"+" .... "+scope.manager);
          state.go("home");
  
      }
      else if(response.data == "admin")
      {
          scope.admin=response.data;
          alert("The user is admin"+" ..... "+scope.admin);   
          state.go("home");
      }
  
      else
      {
          alert(" ID/Password is Invalid...");
          state.go("landingPage");
      }
  
      });
  };
  }
  ]);
  </code></pre>