I wrote an Angular service that gets some fake data from my C# backend. The C# backend is using an ASMX file for the process. I have data coming back and everything is all nice and then my data never populates.
I have this feeling it has something to do with the data pass off coming back from the promise.
Service:
app.service('fakeDataCenter', function ($http) {
this.getFakeData = function ()
{
var obj = {
phoneNumber: "",
faxNumber: "",
address: "Loading..",
};
$.ajax({
type: "POST",
url: "/Services/DataService.asmx/getFakeData",
cache: false,
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: function(data, status){
obj = data;
}
});
return obj;
};});
I can tell that I hit return obj, before I hit the line obj = data. How do I make the code return only after data has been populated.
I have already tried putting the return statement inside the success function without any luck. It just returns an undefined object.