【发布时间】:2015-06-25 07:50:05
【问题描述】:
我想实现一个子状态来获取数据到主状态。当我处于子状态时,我想在父状态的视图上显示 $ionicLoading 内容,并且在加载数据后它应该离开子状态并返回父状态。如何使用 angularjs/ionicframework 实现这一点?
我要拆分的状态的控制器如下所示:
.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 -----------//
...
});
【问题讨论】: