0

I would like to make a synchronous call to server using angular. Something similar to below jquery functionality.

var response = $.ajax(
        {
            type: "POST",
            url: "url",
            data: "data",
            async: false,
        }).responseText;

Thanks

Venkat
  • 853
  • 10
  • 26

1 Answers1

0

Angular doesn't have any functions included which are synchronous. You'll have to write something custom with XHR or you'll have to just use a promise. Any reason why you can't use a promise? Angular does have a service called $q which can help you with promises. The default $http service returns a promise.

Jonathan Rowny
  • 7,588
  • 1
  • 18
  • 26
  • Can you please share some links how to use $q or share some code. I tried some but i couldn't able to do that. – Venkat Jan 25 '14 at 01:51