Within my ASP.NET Boilerplate project, the following code snippet is present:
(function () {
appModule.controller('augustinum.views.kostenstelle.index', [
'$scope', '$uibModal', 'abp.services.app.kostenstelle',
function ($scope, kostenstelleService) {
var vm = this;
vm.kostenstellen = [];
vm.getKostenstelle = function () {
kostenstelleService.getKostenstelle().then(function (result) {
vm.kostenstellen = result.items;
console.log("Step1" + vm.kostenstellen.length);
});
};
vm.getKostenstelle();
console.log("Step2" + vm.kostenstellen.length);
}
]);
})();
There are two queries that I have:
An error message is displayed:
getKostenstelle() is not a function.
If I substitute
withkostenstelleService.getKostenstelle()
, the code functions correctly — the object listabp.services.app.kostenstelle.getKostenstelle()
Kostenstelle
is retrieved. Nonetheless, I believe I lose the scope with this workaround. Therefore, what is the issue with thekostenstelleService
?Upon successful code execution (after replacing
kostnestelleService
), the arraykostenstelle[]
contains2
items. In the line with"Step1"
, the accurate count of2
items is displayed. However, at the line with"Step2"
,0
elements are shown. Why is this the case? Moreover, how can I modify the code so that the line with"Step2"
is executed when the array is populated?
Thanks in advance for any guidance.