添加加载栏Ionic App - Angular

Sad*_*yan 2 angularjs angular-ui-router ionic-framework

如何loading or please waiting在两条路线之间添加一个.

例如,当我转到类似details.html的页面时,这个pas有http直到页面加载用户看到一个空白页面.

我想要这样的东西:

厂

 .factory('DrupalNode', function ($http, $stateParams, REMOTE_URL) {

        return {
            node: $http.get(REMOTE_URL + 'all/')

//////////////// please wait

        }
    });  
Run Code Online (Sandbox Code Playgroud)

调节器

app.controller('detailController', function($scope, DrupalNode, $state, $window){

    DrupalNode.node.success(function(data){  

/////////disappear waiting text 


        $scope.innerData = data;
        $scope.whichArticle = $state.params.Nid;
        console.log(data);


    });
    $scope.goBack = function() {
        $window.history.back();
    };

});
Run Code Online (Sandbox Code Playgroud)

Mud*_*jaz 7

使用离子的$ ionicLoading服务.show()在控制器启动hide()时调用它的功能,当你从api得到响应时.

  app.controller('detailController', function($scope, DrupalNode, $state, $window, $ionicLoading){
            $ionicLoading.show({
              template: 'Loading text goes here...'
            });
            DrupalNode.node.success(function(data){  
            $ionicLoading.hide();
        /////////disappear waiting text 


                $scope.innerData = data;
                $scope.whichArticle = $state.params.Nid;
                console.log(data);


            });
            $scope.goBack = function() {
                $window.history.back();
            };

        });
Run Code Online (Sandbox Code Playgroud)

如果你想在加载中显示一些文本,那show()就像这样使用

    $ionicLoading.show({
      template: 'Loading text goes here...'
    });
Run Code Online (Sandbox Code Playgroud)