I am trying to make use of the variable StatusASof within the inserthtml function in the following manner.
App.controller("SS_Ctrl", function ($scope, $http, $location, $window, $sce, $q) {
var ShiftDetails = [];
function acquireMAStatusASof(Id) {
var defer = $q.defer();
$http({
method: 'GET',
url: 'http://xx/api/Sxxx/GetMAStatusASof',
params: { Id: Id }
}).then(function successCallback(response) {
StatusASof = response.data;
alert("acquireMAStatusASof : " + StatusASof);
defer.resolve(response);
}, function errorCallback(response) {});
}
function insertHtml(dates, ShiftDetails, Id) {
// var promise = acquireMAStatusASof(Id); promise.then(
var defer = $q.defer();
acquireMAStatusASof(Id);
alert(StatusASof);
defer.resolve();
var Content;
Content = '<table class="clsTable"> <tr> <td rowspan="2">Cases ' + $scope.StatusASof + ' </td> <td rowspan="2">Total</td> ';
for (var i = 0; i <= 6; i++) {
if (i == daySeq - 1) {
Content = Content + '<td colspan="3" style="background-color:red"> {{dates[ ' + i + ']}} </td> ';
}
}
}
However, $scope.StatusASof remains undefined when attempting to display the outcome. It appears that $q.defer is not functioning as expected.
What steps can I take to ensure that the code continues execution only after receiving data from getMAStatusASof(Id);
If anyone could provide assistance with this issue, it would be greatly appreciated.