0

I have a C# bool method that is called and executed on the client through AngularJS. The method works without any error as I have confirmed but the string result (result.toString()) of the execution (true or false) displays [Object Object] instead. Below is the script function;

vm.isActiveCustomer = function(sp) {
     abp.ui.setBusy();
     var result = sessionService.isActiveCustomer({
         id: sp.id
     }).success(function() {
         abp.notify.info(result.toString());
     }).finally(function() {
         abp.ui.clearBusy();
     });        
}

It looks simple but I can't get it to display what I want. Please Help.

BrTkCa
  • 4,703
  • 3
  • 24
  • 45
Kacey Ezerioha
  • 1,068
  • 4
  • 22
  • 46
  • try var result = JSON.stringify(result). Then print the result var. – user2263572 Sep 22 '16 at 20:12
  • Maybe result is an array, what's show in console.log(result); ? – BrTkCa Sep 22 '16 at 20:18
  • @user2263572 Thank for your response. I tried it and it gave me this: `{"$$state":"status":0}`. Again, not what I need. – Kacey Ezerioha Sep 22 '16 at 20:20
  • whoa, what? that's not valid json at all, you couldn't have possibly gotten that. – Kevin B Sep 22 '16 at 20:21
  • `{$$state: Object} $$state : Object status : 1 value : Object config : Object data : false headers : (d) status : 200 statusText : "OK" __proto__ : Object __proto__ : Object __proto__ : Object` I got that when i ran console.log(result) – Kacey Ezerioha Sep 22 '16 at 20:24

1 Answers1

1

You are missing an argument to the success callback. result is a likely a promise and handling an async request. You'll have to keep the flow and keep it async.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • Could you throw more light to what you just said? Actually the method it's executing is an async method. But I don't see how it isn't yielding the desired result. – Kacey Ezerioha Sep 22 '16 at 20:29
  • 1
    @KaceyEzerioha http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call – Daniel A. White Sep 22 '16 at 20:29
  • Very long answer it has got and it took me a while to understand it. Thanks for pointing me to it. – Kacey Ezerioha Sep 22 '16 at 22:03