頁面加載完成事件(非刷新狀況下,頁面切換是不會重複觸發此事件的,只在第一次進入頁面時觸發,須要重複觸發的話請使用 $ionicView.enter 事件)angularjs
angular.module('app.controllers', []) .controller('page6Ctrl', ['$scope', '$http', '$stateParams', '$ionicLoading', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller // You can include any angular dependencies as parameters for this function // TIP: Access Route Parameters for your page via $stateParams.parameterName function($scope, $http, $stateParams, $ionicLoading) { $scope.$on('$ionicView.loaded', function(event, data) { $ionicLoading.show(); $http.get("js/123.json") .success(function(res) { $ionicLoading.hide(); }); }); } ])
其餘事件以下:json
$ionicView.loaded |
The view has loaded. This event only happens once per view being created and added to the DOM. If a view leaves but is cached, then this event will not fire again on a subsequent viewing. The loaded event is good place to put your setup code for the view; however, it is not the recommended event to listen to when a view becomes active. |
$ionicView.enter |
The view has fully entered and is now the active view. This event will fire, whether it was the first load or a cached view. |
$ionicView.leave |
The view has finished leaving and is no longer the active view. This event will fire, whether it is cached or destroyed. |
$ionicView.beforeEnter |
The view is about to enter and become the active view. |
$ionicView.beforeLeave |
The view is about to leave and no longer be the active view. |
$ionicView.afterEnter |
The view has fully entered and is now the active view. |
$ionicView.afterLeave |
The view has finished leaving and is no longer the active view. |
$ionicView.unloaded |
The view's controller has been destroyed and its element has been removed from the DOM. |
$ionicParentView.enter |
The parent view has fully entered and is now the active view. This event will fire, whether it was the first load or a cached view. |
$ionicParentView.leave |
The parent view has finished leaving and is no longer the active view. This event will fire, whether it is cached or destroyed. |
$ionicParentView.beforeEnter |
The parent view is about to enter and become the active view. |
$ionicParentView.beforeLeave |
The parent view is about to leave and no longer be the active view. |
$ionicParentView.afterEnter |
The parent view has fully entered and is now the active view. |
$ionicParentView.afterLeave |
The parent view has finished leaving and is no longer the active view. |
官方文檔:http://ionicframework.com/docs/api/directive/ionView/api
關於$http和$ionicLoading對象,要在控制器使用ionic系統對象的時候,只須要在第二參數里加入變量,而後在最後的函數參數裏也加入參數就能夠了app