-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices.js
More file actions
161 lines (137 loc) · 4.86 KB
/
services.js
File metadata and controls
161 lines (137 loc) · 4.86 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
angular.module('starter.services', [])
.factory('Chats', function() {
// Might use a resource here that returns a JSON array
// Some fake testing data
var chats = [{
id: 0,
name: 'Ben Sparrow',
lastText: 'You on your way?',
face: 'img/ben.png'
}, {
id: 1,
name: 'Max Lynx',
lastText: 'Hey, it\'s me',
face: 'img/max.png'
}, {
id: 2,
name: 'Adam Bradleyson',
lastText: 'I should buy a boat',
face: 'img/adam.jpg'
}, {
id: 3,
name: 'Perry Governor',
lastText: 'Look at my mukluks!',
face: 'img/perry.png'
}, {
id: 4,
name: 'Mike Harrington',
lastText: 'This is wicked good ice cream.',
face: 'img/mike.png'
}];
return {
all: function() {
return chats;
},
remove: function(chat) {
chats.splice(chats.indexOf(chat), 1);
},
get: function(chatId) {
for (var i = 0; i < chats.length; i++) {
if (chats[i].id === parseInt(chatId)) {
return chats[i];
}
}
return null;
}
};
});
angular.module('starter.directives', [])
.directive('lifeCycle', lifeCycle);
lifeCycle.$inject = ['$stateParams', '$timeout', '$ionicHistory'];
/* @ngInject */
function lifeCycle($stateParams, $timeout, $ionicHistory) {
// Usage:
//
// Creates:
//
var directive = {
link: link,
restrict: 'A',
scope: false,
controller: Controller
// scope: {}
};
return directive;
function link(scope, element, attrs, ctrl) {
console.info('directiveController', ctrl)
var idx = 0;
console.time('loaded')
console.time('beforeEnter')
console.time('enter')
console.time('afterEnter')
console.time('beforeLeave')
console.time('leave')
console.time('afterLeave')
console.time('unloaded')
var _nameView = attrs.viewTitle;
console.log('lifeCycle directive', scope, scope.$id, _nameView, $stateParams);
scope.$on('$ionicView.loaded', function() {
console.log(_nameView + ' loaded', scope, scope.$id);
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('loaded');
});
scope.$on('$ionicView.beforeEnter', function() {
// Anything you can think of
console.log(_nameView + ' BeforeEnter', scope, scope.$id)
console.info('directiveController', ctrl)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('beforeEnter')
console.log(idx);
idx++;
if (_nameView === 'Account') {
$timeout(scope.vm.setName, 2000)
scope.vm.settings.name = _nameView;
scope.vm.add41();
}
});
scope.$on('$ionicView.enter', function() {
console.log(_nameView + ' enter', scope, scope.$id)
console.info('directiveController', ctrl)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('enter')
// Anything you can think of
});
scope.$on('$ionicView.afterEnter', function() {
console.log(_nameView + ' afterEnter', scope, scope.$id)
console.info('directiveController', ctrl)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('afterEnter');
});
scope.$on('$ionicView.beforeLeave', function() {
console.log(_nameView + ' beforeLeave', scope, scope.$id)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('beforeLeave')
// Anything you can think of
});
scope.$on('$ionicView.leave', function() {
console.log(_nameView + ' Leave', scope, scope.$id)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('leave')
});
scope.$on('$ionicView.afterLeave', function() {
console.log(_nameView + ' afterLeave', scope, scope.$id)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('afterLeave')
});
scope.$on('$ionicView.unloaded', function() {
console.log(_nameView + 'unloaded', scope, scope.$id)
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
console.timeEnd('unloaded')
// Anything you can think of
});
}
function Controller() {
vm = this;
vm.test = '0elo'
}
}