Ion Application Launch Event

I have a problem with my corner ionic app. During registration, we load various settings. If I kill the application and run it, these settings will not be loaded.

I need to know if there is an event that is raised when the application starts, so that I can reload my application settings.

thanks

+5
source share
2 answers

You can add lines of code to load parameters either in YourIndex.html Controller , or you can put this code under $ionicPlatform.ready .

Option 1: Run it inside your index.html controller, because every time you open the application, this controller will be loaded.

 var myApp = angular.module('myApp', ['ionic']); myApp.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise('/') $stateProvider.state('index', { url: '/', controller: 'IndexCtrl', }) }); myApp.controller('IndexCtrl', function($scope) { //load your settings from localStorage or DB where you saved. }); 

Option 2: Called every time Ionic calls deviceReady .

 var myApp = angular.module('myApp', ['ionic']); myApp.run(function($ionicPlatform) { $ionicPlatform.ready(function() { //load your settings from localStorage or DB where you saved. }); }); 
+11
source

In case someone is looking for ionic 2 or 3, the solution is:

 export class MyApp { constructor() { platform.ready().then(() => { //DO WHATEVER }); } } 
0
source

All Articles