Hello,
I want to give a factory which provides data to a controller a own state. For example I have a list to show and a factory which provides the data. I want that while the factory providing the data $ionicLoading content is shown and the state should be other than the state of showing the list. After the data is finished loading the state should jump to the list view state. While the factory is providing the data it should not change the view of the list view state. It just have to open $ionicLoading content. I tried it which creating nested states but could not bring it to work the way I like to.
Here is my list view controller:
.controller(‘MainCtrl’, function ($scope, $ionicPopover, $state, $ionicLoading, $ionicPlatform, $q, WebService, DBService) {
//------ THIS PART SHOULD GO INTO THE CHILD STATE -----//
$ionicLoading.show({
template: “Daten werden geladen…”,
animation: “fade-in”,
showBackdrop: false,
maxWidth: 200,
showDelay: 500
});
$ionicPlatform.ready(function() {
$ionicPopover.fromTemplateUrl('templates/popover.html', { scope: $scope }).then(function (popover) { $scope.popover = popover; });
DBService.dropTables();
DBService.createAllTables();
WebService.getAllTables().then(function(res) {
$ionicLoading.hide();
$scope.refreshDestinations(); //DATA is loaded leave the child state
}, function(err) {
$ionicLoading.hide();
//Change the state to login $state.go('app.login');
});
});
//----------- UNTIL HERE -----------//
…
});
How can I implement this?