2013-11-22 23 views
0
login_app.factory('login_service', function ($http) {                                
    return {                                           
     login: function (user,pass) {                                    
      //return the promise directly.                                   
      return $http({                                       
          url:"/service/login",                                  
          method:"POST",                                    
          data:JSON.stringify({username:user,password:pass})                           

          }).success(function (data, status, headers, config) {                          
           // assign $scope.persons here                              
           // as promise is resolved here                               
           localStorage.setItem("auth_token",headers("X-Auth-Token"));                       
           window.location = "/layout/dashboard"                            
          }).error(function (data, status, headers, config) {                          

           // If I have a custom alert box, should I display it from 
           // or I should use a directive for bootstrap alert-box. 
           // But what should I do here so that Alertbox knows it is 


          });                                      
     }                                           
    }                                            
}); 

回答

2

有很多方法,每個人都根據自己的需要正確使用。

我把引導警報到對話框:

enter image description here

演示Plunker