Answer the question
In order to leave comments, you need to log in
How to implement your analogue of confirm in angular?
Greetings.
I need a dialog that works similar to calling confirm. That is, a dialog appears and code execution stops until a result is returned.
I tried using an infinite loop,
var confirmResult = -1;
$rootScope.$emit('showConfirmDialog','Are you sure?');
var deregFunc = $rootScope.$on('confirmDialogResult',function(e,result){
//сообщение от диалога после клика на кнопку.
confirmResult = result;
});
while(confirmResult === -1){
}
alert(confirmResult);
deregFunc();
Answer the question
In order to leave comments, you need to log in
does it make sense to do so?
you can also call the desired function in the confirmation handler (in extreme cases, emit another event), and block all input fields through an overlay above the document
You make a service, everything else is in it. As for "stop everything and everyone" - it depends on what exactly you want to stop. Usually it is enough to add an overlay to prevent user actions, and you can also add a request interceptor that will wedged into the promise chain and suspend all requests for the time you need.
And yes, an infinite loop is brilliant ... You have everything running in one thread, and js, and rendering and processing user input and actions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question