title: How to make a "for loop" synchronous in angularJs?
body: <p>I am trying to get the user details from backend server, i am getting the details but not in order, Details are getting mixed to each other.
  My controller code is here</p>
  
  <pre><code>function addRecentDetailsToDestination(array) {
               for (var i = 0; i &lt; array.length; i++) {
                   var value = array[i];
             userService.RetrieveRecentEduDetail(value.destinationId, function (rResponse) {
                       if (rResponse.success) {
                           value.destRecentEducationAvailable = true;
                           value.destRecentEducationName = rResponse.data.educationName;
  
                           userService.RetrieveCollege(rResponse.data.colCode, function (cResponse) {
                               if (cResponse.success) {
                                   value.destRecentCollegeName = cResponse.data.colName;
                               } else {
  
                               }
                           });
  
                       } else {
                           value.destRecentEducationAvailable = false;
  
                       }
                       alert(console.log(value.destRecentEducationName));
                   });
  
                   userService.RetrieveRecentProfessionDetail(value.destinationId, function (response) {
                       if (response.success) {
                           value.destRecentProfessionAvailable = true;
                           value.destRecentProfessionRole = response.data.professionRole;
                           value.destRecentProfessionCompany = response.data.professionCompany;
  
  
                       } else {
                           value.destRecentProfessionAvailable = false;
                       }
                   });
                 });
               }
           }
  </code></pre>
  
  <p>This code is working fine, but not getting proper result, please help me
  and i am calling the function like this</p>
  
  <pre><code> userService.RetrieveUserConnectionsBySourceId(userId, function (response) {
  
                   if (response.success) {
                       $scope.userConnectionsBySource = response.data;
  
                       addRecentDetailsToDestination($scope.userConnectionsBySource);
  
                   } else {
                       FlashService.Error(response.message);
                   }
               });
  </code></pre>