title: How to wait function call return value before go to the next line in angular js
body: <p>I have two functions <strong>is_exist()</strong> and <strong>save()</strong> functions.
  In save function I calls <strong>is_exist()</strong> function before performing a save.it return boolean value.
  but my problem is <strong>save()</strong> function is not wait until <strong>is_exist()</strong> function to return the value.after <strong>is_exist()</strong> function called it just jump into next line and continue execute bellow lines, after <strong>save()</strong> finished <strong>is_exist()</strong> function return the value</p>
  
  <pre><code>var app = angular.module('my_app', [])
  app.controller('my_con', ['$scope', '$http', function($scope, $http) {
  
      $scope.save = function(sector) {
          var del_status = $scope.is_exist(sector);
  
          console.log(del_status); // is_exsis return value
  
          if(!del_status) {
              // save
          }
      }
  
      $scope.is_exist = function(sector) {
          $http({
              method : 'POST',
              url : '/is_data_exist',
              contentType : 'application/json; charset=utf-8',
              data : angular.toJson({
                  'sector': sector
              }),
              dataType: 'json',
          }).then(function successCallback(response) {
  
              console.log(response.data); //http respond
  
              if(response.data == 'False') {
                  return false;
              }
              else {
                  return true;
              }
          })
      }
  }])
  </code></pre>
  
  <p>is there any way to wait until <strong>is_exsis()</strong> function to return value and then go to next line</p>