Requesting help with my Angular controller. I am trying to display items from both variables x
and y
on the webpage, but currently it only shows items from variable y
. I attempted to combine the two function result sets using .push()
into the PremByClass
array. Any guidance or assistance on how to achieve this would be highly appreciated.
app.controller('PremByClass', ['$scope', '$http', 'policyApi', 'lookupApi', function ($scope, $http, policyApi, lookupApi) {
$scope.model = {};
$scope.load.then(function () {
function formatDate(value) {
return value.getMonth() + 1 + "-" + value.getDate() + "-" + value.getFullYear();
}
$scope.PremByClass = [];
policyApi.policy.get().then(function (t) {
if (t) {
policyApi.class.get().then(function (x) {
if (x) {
//Include x in $scope.PremByClass
$scope.PremByClass.push(x);
var dtEff = formatDate(t.DateEffective);
for (var i = 0, e = null; e = x[i]; i++) {
lookupApi.WCClassDesc.get(e.GovState, e.classCode, e.DescCode, dtEff).then(function (y) {
//The process seems correct but $scope.PremByClass neglects x
//Webpage only displays y data
$scope.PremByClass.push(y);
})
}
}
})
}
})
});
}]);