Sunday, December 6, 2015

Web Service Call using Angulat JS


By using below code base we can do the web service call in Angular JS

 var req = {  
   method: 'GET',  
   url: LOGIN_URL,  
   params: {  
     registrationId: document.getElementById("username").value,  
     dob: document.getElementById("dob").value  
   }  
 }  
 $http(req).success(function(data, status, headers, config) {  
   var result = data;  
   if (result.status == 2) {  
     localStorage.permId = document.getElementById("username").value;  
     localStorage.applicantName = result.applicantName;  
     localStorage.Dob = result.Dob;  
     localStorage.mobileno = result.mobileno;  
     localStorage.Gender = result.Gender;  
     window.location.href = 'profile.html';  
   } else {  
     $scope.loading = false;  
     alert(data.returnObj2);  
     //Alert.render(data.returnObj2);  
   }  
 }).error(function() {  
   $scope.loading = false;  
   alert("Service is not available");  
   //AlertLogin.render();  
   //Alert.render("Service is not available");  
 });  

1 comment: