0

I am not able to bind the scope variables to the get service in controller.

My service file
app.service('loginService', function ($http) {

    var Service = {};
    Service.getLogin = function () {

        return $http.get('http://183.8/HMS/Service1.svc/LoginVerification/');

    };

    return Service;

})

and in my controller i have to use above service like below by passing email id and password

loginService.getLogin( + $scope.emailId + '/' + $scope.password);

without service i am able to get the solution but with service this two parameters are not binding to URL,Any solution please help.

5
  • where do you handle + $scope.emailId + '/' + $scope.password in your service Commented Jan 6, 2016 at 5:40
  • @RohanPawar the complete url given by API Team is 183.82/HMS/Service1.svc/LoginVerification{EMAILID}/{PASSWORD} Commented Jan 6, 2016 at 5:42
  • you need to bind parameter to url Commented Jan 6, 2016 at 5:44
  • @RohanPawar I am new to angular and i dont know how to bind this parameters please help. Commented Jan 6, 2016 at 5:45
  • checkout my answer as well Commented Jan 6, 2016 at 5:59

2 Answers 2

1

Service function should return the new Object, something like this

  var Service = function(){
           this.getLogin = function (email,password) {
                return $http.get('http://183.8/HMS/Service1.svc/LoginVerification/'+email+'/'+password);

            };
     }       
    return new Service();

and call your service like this

loginService.getLogin( $scope.emailId , $scope.password);

or change the service function to factory

app.factory('loginService', function ($http) {
Sign up to request clarification or add additional context in comments.

1 Comment

I have tried your solution but they are not binding to url
1

try this

app.service('loginService', function ($http) {

        function getLoginCall(url) {
            return $http.get('http://183.8/HMS/Service1.svc/LoginVerification/'+url);
        }

        return {
            getLogin:getLoginCall
        };

    });

and in your contorller

loginService.getLogin($scope.emailId + '/' + $scope.password);

Comments

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.