离子应用启动事件 [英] ionic application startup event

查看:104
本文介绍了离子应用启动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的angularjs离子应用程序有问题。在登录期间,我们正在加载各种设置。如果我杀了应用程序并重新启动它,则不会加载这些设置。

I have a problem with my angularjs ionic application. During login we're loading various settings. If I kill the app and re-launch it these settings are not loaded.

我需要知道在应用程序启动时是否有一个事件被调用,以便我可以重新加载我的应用设置。

I need to know if there's an event that is being invoked when the application launches so that I can reload my app settings.

谢谢

推荐答案

你可以添加代码行以在 YourIndex.html的控制器中加载设置,或者您可以将该代码放在 $ ionicPlatform.ready 下。

You can add the lines of code to load the settings either in YourIndex.html's Controller or you can put that code under $ionicPlatform.ready.

选项1: index.html 的控制器中运行它,因为每次打开应用程序时,此控制器将被加载。

Option 1: Run it inside your index.html's controller, because every time you open your app, 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.
});

选项2:每次离线拨打电话 deviceReady

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

这篇关于离子应用启动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆