我的
angularjs离子应用程序有问题.登录时我们正在加载各种设置.如果我终止该应用并重新启动它,则不会加载这些设置.
我需要知道在应用程序启动时是否有一个事件被调用,以便我可以重新加载我的应用程序设置.
谢谢
解决方法
您可以添加代码行以在YourIndex.html的Controller中加载设置,也可以将该代码放在$ionicPlatform.ready下.
选项1:在index.html的控制器中运行它,因为每次打开应用程序时,都会加载此控制器.
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:每次Ionic拨打deviceReady时拨打电话.
var myApp = angular.module('myApp',['ionic']); myApp.run(function($ionicPlatform) { $ionicPlatform.ready(function() { //load your settings from localStorage or DB where you saved. }); });