Listenrefresh und Datashare-service eingebaut
This commit is contained in:
parent
23beeb7e8c
commit
0d1b440b7d
@ -343,8 +343,7 @@ angular.module('starter', ['ionic','ngIOS9UIWebViewPatch','starter.controllers',
|
||||
url: "/pokemonlist",
|
||||
cache: true,
|
||||
params:{
|
||||
isAnimated:(ionic.Platform.isAndroid()==false),
|
||||
controllersettings: null
|
||||
isAnimated:(ionic.Platform.isAndroid()==false)
|
||||
},
|
||||
views: {
|
||||
'menuContent': {
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
<p> Clear All Data</p>
|
||||
</md-list-item>
|
||||
<md-list-item class="md-list-item-default" ng-click="navigateTo('app.pokemonlist', {isAnimated:false,controllersettings:{test:'Laola',refresh:'1'}})">
|
||||
<md-list-item class="md-list-item-default" ng-click="refreshData()">
|
||||
<i class="ion-android-refresh"></i>
|
||||
|
||||
<p>Refresh Data</p>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
// http://ngcordova.com/docs/plugins/sqlite/
|
||||
//
|
||||
// Controller of Pokemon List Page.
|
||||
appControllers.controller('pokemonListCtrl', function ($scope, $stateParams,$ionicScrollDelegate, $filter, $mdDialog, $timeout, $ionicModal, $state, $mdBottomSheet, $ionicHistory,pokedexDB) {
|
||||
appControllers.controller('pokemonListCtrl', function ($scope, $stateParams,$ionicScrollDelegate, $filter, $mdDialog, $timeout, $ionicModal, $state, $mdBottomSheet, $ionicHistory,pokedexDB, dataShare) {
|
||||
|
||||
// initialForm is the first activity in the controller.
|
||||
// It will initial all variable data and let the function works when page load.
|
||||
@ -94,29 +94,16 @@ appControllers.controller('pokemonListCtrl', function ($scope, $stateParams,$ion
|
||||
$scope.initialForm();
|
||||
});
|
||||
|
||||
|
||||
$scope.$on('$ionicView.enter', function(viewInfo, state){
|
||||
console.log('ENTERED');
|
||||
$scope.controllersettings = $stateParams.controllersettings;
|
||||
if ($scope.controllersettings.refresh=='1'){
|
||||
console.log("refreshed");
|
||||
$scope.getPokemonList();
|
||||
$timeout(function(){
|
||||
$state.go('app.pokemonlist',
|
||||
{
|
||||
isAnimated:false,
|
||||
controllersettings:
|
||||
{
|
||||
test:'Laola',
|
||||
refresh:'0'
|
||||
$scope.$on('data_shared',function(){
|
||||
var data = dataShare.getData();
|
||||
if (data=='refresh'){
|
||||
$scope.initialForm();
|
||||
console.log('refresched');
|
||||
}
|
||||
}
|
||||
);
|
||||
},400);
|
||||
}
|
||||
console.debug($scope.controllersettings);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});// End of Pokemon List Page Controller.
|
||||
|
||||
// Controller of pokemon Detail Page.
|
||||
@ -269,7 +256,7 @@ appControllers.controller('pokemonDetailCtrl', function ($mdBottomSheet, $mdToas
|
||||
});// End Contract Detail page Controller.
|
||||
|
||||
// Controller of Contract Setting Page.
|
||||
appControllers.controller('pokemonSettingCtrl', function ($scope,$ionicViewSwitcher,$state, $timeout, $stateParams, $mdDialog, $mdBottomSheet, $mdToast, $ionicHistory, pokedexDB) {
|
||||
appControllers.controller('pokemonSettingCtrl', function ($scope,$ionicViewSwitcher,$state, $timeout, $stateParams, $mdDialog, $mdBottomSheet, $mdToast, $ionicHistory, pokedexDB, dataShare) {
|
||||
|
||||
// initialForm is the first activity in the controller.
|
||||
// It will initial all variable data and let the function works when page load.
|
||||
@ -346,7 +333,9 @@ appControllers.controller('pokemonSettingCtrl', function ($scope,$ionicViewSwitc
|
||||
};// End clear all data from sqlite
|
||||
|
||||
$scope.refreshData=function(){
|
||||
|
||||
var data='refresh';
|
||||
dataShare.sendData(data);
|
||||
$scope.navigateTo('app.pokemonlist', {isAnimated:false});
|
||||
};
|
||||
|
||||
// navigateTo is for navigate to other page
|
||||
@ -363,10 +352,8 @@ appControllers.controller('pokemonSettingCtrl', function ($scope,$ionicViewSwitc
|
||||
|
||||
//Next view animate will display in back direction
|
||||
$ionicViewSwitcher.nextDirection('back');
|
||||
|
||||
$state.go(stateName, {
|
||||
isAnimated: objectData.isAnimated,
|
||||
controllersettings: objectData.controllersettings,
|
||||
isAnimated: objectData.isAnimated
|
||||
});
|
||||
}
|
||||
}; // End of navigateTo.
|
||||
|
||||
@ -470,4 +470,20 @@ appServices.factory('pokedexDB', function ($cordovaSQLite)
|
||||
})
|
||||
},// End remove all data from sqlite.
|
||||
};
|
||||
}); //End ContractDB service.
|
||||
});
|
||||
|
||||
appServices.factory('dataShare', function ($rootScope,$timeout)
|
||||
{
|
||||
var service = {};
|
||||
service.data = false;
|
||||
service.sendData = function(data){
|
||||
this.data = data;
|
||||
$timeout(function(){
|
||||
$rootScope.$broadcast('data_shared');
|
||||
},100);
|
||||
};
|
||||
service.getData = function(){
|
||||
return this.data;
|
||||
};
|
||||
return service;
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user