Calling wcf in factory?


#1

Hello so i’m new and trying to call Web service to get data. Got some problem and don’t know why could someone review this?


#2

Hey @Endiss,

I’ve updated your codepen to do what you want!

Check:

The angular $http object works with promises, and the requests are asynchronous. You cannot therefor return the value directly, because it is not available at the time of calling the function. By using a callback method like in my example, you are able to delay processing of the data untill the moment the data is actually fetched by the $http call.

Hope you’ll see what I mean when looking at the codepen :wink:


#3

Thank you :slight_smile: I understand now … Cheers!


#4

@iwantwin 1 more question How to tell him to use Content-Type JSON?


#5

What exactly do you want to tell to use conten-type JSON?

I don’t think I get it :wink: Angular $http.get will use json just as in your example (reference)

Also the API call you provided had correct headers: Content-Type:application/json


#6

@iwantwin just one last quick question how to use params in that codepen that you reviewed?


#7

What kind of params do you mean?

EDIT: you might have some use from this topic: How do I obtain $stateParams in Angular sevice


#8

My Url is WCF/LoginUser?user={userName}&pass={password}
so need to pass this to WCF and thinking is there any call in IONIC to pass them or i need to build URL with this ?


#9

Something like this would work:


#10

Thank you :slight_smile: Hope this post will help other people too:)