Skip to content

Commit cc462f2

Browse files
APP LINK WORKING
1 parent 3866d8b commit cc462f2

File tree

7 files changed

+104
-56
lines changed

7 files changed

+104
-56
lines changed

www/js/app.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,23 @@ angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', '
4141
// Each tab has its own nav history stack:
4242

4343
.state('tab.dash', {
44-
url: '/dash',
45-
views: {
46-
'tab-dash': {
47-
templateUrl: 'templates/tab-dash.html',
48-
controller: 'DashCtrl'
44+
url: '/dash',
45+
views: {
46+
'tab-dash': {
47+
templateUrl: 'templates/tab-dash.html',
48+
controller: 'DashCtrl'
49+
}
4950
}
50-
}
51-
})
51+
})
52+
.state('tab.extra', {
53+
url: '/extra',
54+
views: {
55+
'tab-extra': {
56+
templateUrl: 'templates/tab-extra.html',
57+
controller: 'DashCtrl'
58+
}
59+
}
60+
})
5261

5362
.state('tab.chats', {
5463
url: '/chats',

www/js/controllers.js

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,60 @@ angular.module('starter.controllers', [])
22

33
.controller('DashCtrl', function($scope) {
44

5-
/* $scope.$on('$ionicView.loaded', function() {
6-
console.log(' DashCtrl loaded', $scope, $scope.$id)
7-
});
8-
9-
$scope.$on('$ionicView.beforeEnter', function() {
10-
// Anything you can think of
11-
console.log(' DashCtrl BeforeEnter', $scope, $scope.$id)
12-
});
13-
$scope.$on('$ionicView.enter', function() {
14-
// Anything you can think of
15-
console.log(' DashCtrl enter', $scope, $scope.$id)
165

17-
});
18-
$scope.$on('$ionicView.afterEnter', function() {
19-
console.log(' DashCtrl afterEnter', $scope, $scope.$id)
20-
});
6+
console.info('DashCtrl');
7+
/* $scope.$on('$ionicView.loaded', function() {
8+
console.log(' DashCtrl loaded', $scope, $scope.$id)
9+
});
2110
22-
$scope.$on('$ionicView.beforeLeave', function() {
23-
console.log(' DashCtrl beforeLeave', $scope, $scope.$id)
11+
$scope.$on('$ionicView.beforeEnter', function() {
2412
// Anything you can think of
25-
});
13+
console.log(' DashCtrl BeforeEnter', $scope, $scope.$id)
14+
});
15+
$scope.$on('$ionicView.enter', function() {
16+
// Anything you can think of
17+
console.log(' DashCtrl enter', $scope, $scope.$id)
2618
27-
$scope.$on('$ionicView.leave', function() {
28-
console.log(' DashCtrl Leave', $scope, $scope.$id)
29-
});
19+
});
20+
$scope.$on('$ionicView.afterEnter', function() {
21+
console.log(' DashCtrl afterEnter', $scope, $scope.$id)
22+
});
3023
31-
$scope.$on('$ionicView.afterLeave', function() {
32-
console.log(' DashCtrl afterLeave', $scope, $scope.$id)
24+
$scope.$on('$ionicView.beforeLeave', function() {
25+
console.log(' DashCtrl beforeLeave', $scope, $scope.$id)
26+
// Anything you can think of
27+
});
3328
34-
});
35-
$scope.$on('$ionicView.unloaded', function() {
36-
console.log(' DashCtrl unloaded', $scope, $scope.$id)
37-
// Anything you can think of
38-
});*/
29+
$scope.$on('$ionicView.leave', function() {
30+
console.log(' DashCtrl Leave', $scope, $scope.$id)
31+
});
3932
40-
})
33+
$scope.$on('$ionicView.afterLeave', function() {
34+
console.log(' DashCtrl afterLeave', $scope, $scope.$id)
35+
36+
});
37+
$scope.$on('$ionicView.unloaded', function() {
38+
console.log(' DashCtrl unloaded', $scope, $scope.$id)
39+
// Anything you can think of
40+
});*/
41+
42+
})
43+
.controller('ExtraCtrl', function($scope, $ionicNavBarDelegate, $ionicHistory) {
44+
45+
46+
$ionicNavBarDelegate.showBackButton(true);
47+
48+
$scope.back = function() {
49+
debugger;
50+
$ionicHistory.goBack();
51+
}
52+
53+
54+
})
4155

4256
.controller('ChatsCtrl', function($scope, Chats) {
57+
58+
console.info('ChatsCtrl');
4359
/*$scope.$on('$ionicView.loaded', function() {
4460
console.log(' ChatsCtrl loaded', $scope, $scope.$id)
4561
});

www/js/services.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ angular.module('starter.services', [])
5353
angular.module('starter.directives', [])
5454
.directive('lifeCycle', lifeCycle);
5555

56-
lifeCycle.$inject = ['$stateParams', '$timeout'];
56+
lifeCycle.$inject = ['$stateParams', '$timeout', '$ionicHistory'];
5757

5858
/* @ngInject */
59-
function lifeCycle($stateParams, $timeout) {
59+
function lifeCycle($stateParams, $timeout, $ionicHistory) {
6060
// Usage:
6161
//
6262
// Creates:
@@ -83,11 +83,14 @@ function lifeCycle($stateParams, $timeout) {
8383
console.log('lifeCycle directive', scope, scope.$id, _nameView, $stateParams);
8484
scope.$on('$ionicView.loaded', function() {
8585
console.log(_nameView + ' loaded', scope, scope.$id);
86+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
8687
console.timeEnd('loaded');
8788
});
8889
scope.$on('$ionicView.beforeEnter', function() {
8990
// Anything you can think of
9091
console.log(_nameView + ' BeforeEnter', scope, scope.$id)
92+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
93+
9194
console.timeEnd('beforeEnter')
9295
console.log(idx);
9396
idx++;
@@ -99,34 +102,46 @@ function lifeCycle($stateParams, $timeout) {
99102
});
100103
scope.$on('$ionicView.enter', function() {
101104
console.log(_nameView + ' enter', scope, scope.$id)
105+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
106+
102107
console.timeEnd('enter')
103108
// Anything you can think of
104109
});
105110
scope.$on('$ionicView.afterEnter', function() {
106111
console.log(_nameView + ' afterEnter', scope, scope.$id)
112+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
113+
107114
console.timeEnd('afterEnter');
108115
});
109116

110117
scope.$on('$ionicView.beforeLeave', function() {
111118
console.log(_nameView + ' beforeLeave', scope, scope.$id)
119+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
120+
112121
console.timeEnd('beforeLeave')
113122

114123
// Anything you can think of
115124
});
116125
scope.$on('$ionicView.leave', function() {
117126
console.log(_nameView + ' Leave', scope, scope.$id)
127+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
128+
118129
console.timeEnd('leave')
119130

120131
});
121132

122133
scope.$on('$ionicView.afterLeave', function() {
123134
console.log(_nameView + ' afterLeave', scope, scope.$id)
135+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
136+
124137
console.timeEnd('afterLeave')
125138

126139

127140
});
128141
scope.$on('$ionicView.unloaded', function() {
129142
console.log(_nameView + 'unloaded', scope, scope.$id)
143+
console.log('$ionicHistory currentState ' + $ionicHistory.currentStateName())
144+
130145
console.timeEnd('unloaded')
131146
// Anything you can think of
132147
});

www/templates/tab-chats.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ion-view life-cycle view-title="Chats">
1+
<ion-view life-cycle view-title="Chats" cache-view="false">
22
<ion-content>
33
<ion-list>
44
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="chat in chats" type="item-text-wrap" href="#/tab/chats/{{chat.id}}">

www/templates/tab-dash.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ion-view view-title="Dashboard">
1+
<ion-view life-cycle view-title="Dashboard">
22
<ion-content class="padding">
33
<h2>Welcome to Ionic</h2>
44
<p>

www/templates/tab-extra.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ion-view life-cycle view-title="Extra">
2+
<ion-content class="padding">
3+
<h2>extra</h2>
4+
<<button class="button button-dark" ng-click="back()">
5+
back
6+
</button>
7+
</ion-content>
8+
</ion-view>

www/templates/tabs.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
navigation history that also transitions its views in and out.
55
-->
66
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
7+
<!-- Dashboard Tab -->
8+
<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash">
9+
<ion-nav-view name="tab-dash"></ion-nav-view>
10+
</ion-tab>
11+
<!-- Chats Tab -->
12+
<ion-tab title="Chats" icon-off="ion-ios-chatboxes-outline" icon-on="ion-ios-chatboxes" href="#/tab/chats">
13+
<ion-nav-view name="tab-chats"></ion-nav-view>
14+
</ion-tab>
15+
<!-- Account Tab -->
16+
<ion-tab title="Account" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/account">
17+
<ion-nav-view name="tab-account"></ion-nav-view>
18+
</ion-tab>
719

8-
<!-- Dashboard Tab -->
9-
<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash">
10-
<ion-nav-view name="tab-dash"></ion-nav-view>
11-
</ion-tab>
12-
13-
<!-- Chats Tab -->
14-
<ion-tab title="Chats" icon-off="ion-ios-chatboxes-outline" icon-on="ion-ios-chatboxes" href="#/tab/chats">
15-
<ion-nav-view name="tab-chats"></ion-nav-view>
16-
</ion-tab>
17-
18-
<!-- Account Tab -->
19-
<ion-tab title="Account" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/account">
20-
<ion-nav-view name="tab-account"></ion-nav-view>
21-
</ion-tab>
22-
23-
20+
<ion-tab title="extra" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/extra">
21+
<ion-nav-view name="tab-extra"></ion-nav-view>
22+
</ion-tab>
23+
2424
</ion-tabs>

0 commit comments

Comments
 (0)