How to call data from a WCF service?


#1

Hi I have a WCF service connected to a SQL server database.
I am testing with ionic serve in my browser if that makes a difference?
This is what I have tried:

$http.get("http://localhost:53101/Service.svc")
      .success(function(GetData) {
                $scope.employee = GetData; //shows result in html page
                console.log(GetData);
                
                
                
            })
          .error(function(GetData) {
              alert("failure");
            });            

In my console log it shows that I have a connection to the web service (XHR finished loading: GET “http://localhost:53101/Service.svc”.) but I cant seem to figure out how to call a method from the service. Thank you.

P.S if my coding looks wrong on top sorry it may be, I am still learning angularjs (I am a noob) :smile:


#2

it dependence how your wfc looks like^^.

Here is a good and full wfc + angular.js tutorial.
Read the Point: 3. Services.JS
http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/crud-operation-in-mvc4-using-angularjs-and-wcf-rest-services/

It’s like calling any other API --> http://localhost:53101/Service.svc is your base path and you need to add the function name behind: http://localhost:53101/Service.svc/MyGetFunction