Bạn có thể thêm các dòng mã để tải các thiết lập hoặc trong khiển YourIndex.html của hoặc bạn có thể đặt mã dưới $ionicPlatform.ready
.
Lựa chọn 1: Run nó bên khiển index.html của bạn, bởi vì mỗi khi bạn mở ứng dụng của bạn, bộ điều khiển này sẽ được nạp.
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.
});
Phương án 2: Gọi mỗi khi Ionic gọi deviceReady.
var myApp = angular.module('myApp', ['ionic']);
myApp.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
//load your settings from localStorage or DB where you saved.
});
});