-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathapp.js
102 lines (94 loc) · 2.71 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
'use strict';
angular.module('MyApp', [
'ionic',
'firebase',
'MyApp.services',
'MyApp.directives',
'MyApp.controllers'
])
.config(function($stateProvider, $urlRouterProvider) {
var resolve = {
auth: function($q, $timeout, Auth, User) {
var defer = $q.defer();
var state = this;
Auth.getCurrentUser().then(function() {
User.loadCurrentUser().then(function() {
if (state.name === 'change-password') {
defer.resolve();
} else {
if (User.hasChangedPassword()) {
defer.resolve();
} else {
defer.reject('change-password');
}
}
});
}, function() {
$timeout(function() { // See: http://stackoverflow.com/q/24945731/247243
defer.reject('login');
}, 250);
});
return defer.promise;
}
};
$stateProvider
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'sidemenu/sidemenu.html',
controller: 'SideMenuCtrl'
})
.state('signup', {
url: '/signup',
templateUrl: 'signup/signup.html',
controller: 'SignupCtrl'
})
.state('login', {
url: '/login',
templateUrl: 'login/login.html',
controller: 'LoginCtrl'
})
.state('reset-password', {
url: '/reset-password',
templateUrl: 'reset-password/reset-password.html',
controller: 'ResetPasswordCtrl'
})
.state('change-password', {
url: '/change-password',
templateUrl: 'change-password/change-password.html',
controller: 'ChangePasswordCtrl',
resolve: resolve
})
.state('app.dashboard', {
url: '/dashboard',
views: {
menuContent: {
templateUrl: 'dashboard/dashboard.html',
controller: 'DashboardCtrl',
resolve: resolve
}
}
});
$urlRouterProvider.otherwise('/app/dashboard');
})
.run(function($rootScope, $state, $ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory
// bar above the keyboard for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
$rootScope.$on('$stateChangeError', function(event, toState, toParams,
fromState, fromParams, error) {
$state.go(error);
});
});
})
.constant('FIREBASE_ROOT', 'https://myapp.firebaseio.com');
angular.module('MyApp.services', []);
angular.module('MyApp.directives', []);
angular.module('MyApp.controllers', []);