In my setup, I have a controller that calls a service to retrieve a list of categories:
$scope.enquiryCategories = CategoryServices.listCategories();
The service then fetches this data from an external API:
listCategories: function () {
return $http({method: 'GET', url: '/some_external_api/categories.json'}).then(function (result) {
return result.data.custom_field_options;
});
}
When looping through the enquiryCategories in the view, everything seems to be working fine. However, there are cases where the list doesn't display on the initial load, requiring the user to refresh the page. It feels like there might be a timing issue at play, but I'm unsure of what could be causing it.
I've attempted to address this by having listCategories return a promise object, but the problem persists.
My AngularJS version is 1.0.8.
If anyone has any insights or suggestions, they would be greatly appreciated.