0

I have an idea of how to use post method for login, however, our new requirement is my API team has provided get method. How is this used in angular? Please help me. I am stuck on this problem as I am new to angular. Below is the API for get method:

http://183.82.48/HospitalManagementSystem/Service1.svc/LoginVerification/{EMAILID}/{PASSWORD}

1 Answer 1

1

You can try to construct the URI yourself.

<form ng-app="login" ng-controller="loginCtrl">
  <span>Email</span><input ng-model="emailId" type="text" required><br>
  <span>Password</span><input ng-model="password" type="password" required><br>
  <button ng-click="login()">Login</button>
</form>
<script>
var app = angular.module('login', []);
app.controller('loginCtrl', function($scope, $http) {
  $scope.login = function() {
    $http.get('http://183.82.0.48/HospitalManagementSystem/Service1.svc/LoginVerification/' + $scope.emailId + '/' + $scope.password).then(
      function (response) {
        console.log(response.data);
        // ...
      },
      function (error) {
        console.log(error);
        // ...
      }
    )
  }
});
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot i got the solution
hi @trand how to display the logged in user name in my home page
@Sudhir If there is any information in the response returned by your login API, you can add to the markup: <span>Welcome back, {{username}}!</span> and the response callback: $scope.username = response.data.user.name;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.