While I am loading an AngularJS file my code is getting executed completely before the code in .then function completes its execution. How to pause code till the code in .then function executes. I mean I want to make synchronous ajax calls, I used to use async: false
in jQuery. I want to know how to do that in angularJS.
Thanks in advance
Below is my AngularJS
code
var app = angular.module('myApp', [ ]);
app.controller("Ctrl",Ctrl);
function Ctrl($http){
var self=this
ajaxCall();
function ajaxCall(){
return $http.get('/getData/')
.then(function(data){
// this below alert should come before the last alert
alert(" should execute first then below alert")
self.data=data
})
}
alert("getting executed first")
}