2013-11-22 1 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

관련 문제