A
A
apasen2014-06-10 13:11:13
Angular
apasen, 2014-06-10 13:11:13

AngularJS how to make a synchronous request via $http?

How to make a synchronous request via $http?
I'm sorry, I messed up, a synchronous request needs to be executed.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
maxaon, 2014-06-10
@apasen

Um, documentation ?
Don't make a synchronous request.
Change everything so that everything stays asynchronous.
If it is not possible without routes, either inject data directly into the page or do it before the angular AngularJS bootstrap, loading the config before launching the application

S
Sergey, 2014-06-10
Protko @Fesor

all requests to the $http service are asynchronous, moreover, it is highly discouraged to even think about synchronous requests (because this will freeze the entire application, will not process $digest cycles, etc.).
Well, yes, documentation. It's all well written there. I also advise you to read about promises.

A
apasen, 2014-06-10
@apasen

The point is that a synchronous request needs to be executed, because it loads the routes, and without them the client part will not be able to work at all.

M
Mikhail Osher, 2014-06-10
@miraage

Try adding the following js code to the very end of the <body> , provided that you have routes in the $routes variable.
Then the routes constant can be injected anywhere. At least at the configuration stage, at least in the controller, even in the directive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question