1

Topic: Synchronously to receive result of an asynchronous call

Greetings;
Something was at a loss.
There is a function which should return true or false depending on result of an asynchronous call in it. I can not think as it to make. Such variant does not transit:

function Get () {
var result = true;
update ()
.then (function () {//angularjs' promice
result = true;
}).catch (function (ex) {
result = false;
});
return result;
}

Here function always returns true, as a line return result; it is fulfilled earlier, than fulfills update ();. And how to make that Get () returned result depending on result of a call update ()? That is, if the unit catch that function is fulfilled returns false?
(return false; inside catch the same does not work).

2

Re: Synchronously to receive result of an asynchronous call

MyController. $ inject = [...];
function MyController (...)
var vm = this;
...
function Get ();
vm. Result = false;
update ()
.then (function () {//angularjs' promice
vm. Result = true;
}).catch (function (ex) {
vm. Result = false;
});
}

In View  vm. Result

3

Re: Synchronously to receive result of an asynchronous call

... Get ()>>> {<<<

4

Re: Synchronously to receive result of an asynchronous call

Konst_One, but Get () as a result of returns nothing. It is necessary for me that Get () returned true or false as I transfer it in other object, on it depends . There I cannot change anything.

5

Re: Synchronously to receive result of an asynchronous call

What for? That you in view do, show. Or you should cause still a certain method?
If so,  it in.then () or

$rootScope. $ broadcast (' mygetfinish ', somedata)

, And then catch it through

$scope. $ on (' mygetfinish ', function (data) {
//next rules
});

6

Re: Synchronously to receive result of an asynchronous call

Still can .finally ()