I need to have one function call a second function where the second function includes some setup code, an http callback to a REST server and then finely some cleanup code before returning to the first function. The idea is to have the first function then displays a result message after the second function is finished.
The following example returns from the second function before it finishes the callback so I don't get the results of the http success or error.
var saveData = function(_this){
        return new Promise(function(resolve,reject){
        resolve( _this.Save('SavExit') );
    });
};
saveData(this).then(function(httpResponse){
    // display response after http callback finishes
    console.log(httpResponse);
});
this.Save = function (lcAction) {
    // validate data
    $http.post('serverCallback.aspx',oSelectedVendor).
        success(function (data, status, headers, config) {
        // process data before returning;
        return true;
    }).
    error(function(data,status,headers,config){
        console.log(data);
        return false;
    });
};
 
    