I have a phonegap app and want to know when the app goes to background using pause
(http://ift.tt/1C3H3BC) event. document.addEventListener("pause",
yourCallbackFunction, false);
However, I am looking for a way to make yourCallbackFunction trigger the $scope.cancel when the current route is /orders
in the current scope and ignore otherwise. How can I achieve this? Appreciate any help.
Note: Device ready had already been fired by the time I come to this page in the application, so not needed to handle the deviceReady.
Code in context here:
html:
<!doctype html>
<head>
</head>
<body ng-app="myapp">
<!-- Add your site or application content here -->
<div ng-view=""></div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-cookies.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-sanitize.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-route.min.js"></script>
<script src="app/app.js"></script>
</body>
</html>
javascript in app.js:
angular.module('myapp', [ 'ngRoute' ])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', { templateUrl: 'login/login.html', controller: 'LoginCtrl' })
.when('/orders', { templateUrl: 'app/orders/orders.html', controller: 'OrdersCtrl' });
.otherwise({ redirectTo: '/' });
}]);
app.controller('OrdersCtrl', [ '$scope','$filter','$timeout', function($scope,$filter,$timeout,) {
$scope.date = new Date();
$scope.refresh = function(){
getOrders(); //Implemented elsewhere
}
$scope.cancel = function(){
cancelRefresh(); //Implemented elsewhere
}
}]);
Aucun commentaire:
Enregistrer un commentaire