forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavParams.html
More file actions
123 lines (110 loc) · 3.81 KB
/
navParams.html
File metadata and controls
123 lines (110 loc) · 3.81 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
<html ng-app="nav">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>navViews and ion-tabs w/ nested navViews</title>
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
<script src="../../../../dist/js/ionic.bundle.js"></script>
<script src="dom-trace.js"></script>
</head>
<body>
<div>
<ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-icon" from-title>
Back
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view></ion-nav-view>
</div>
<script id="page1.html" type="text/ng-template">
<ion-view title="Page 1">
<ion-nav-buttons side="right">
<button class="button button-icon ion-android-search"></button>
</ion-nav-buttons>
<ion-content padding="true">
<h2>Random {{random}}</h2>
<ion-list>
<div class="item item-divider">
Things
</div>
<ion-item ng-repeat="item in items" ui-sref="page2({itemId: item.id})">
Item {{$index}}
</ion-item>
<div class="item item-divider">
Stuff
</div>
<ion-item ng-repeat="item in items2" ui-sref="page2({item: item})">
Item {{$index}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
</script>
<script id="page2.html" type="text/ng-template">
<ion-view title="Page 2">
<ion-content padding="true">
<h2>Item ID: {{itemId}}</h2>
<a ng-click="goBack()" class="button button-positive">Back</a>
<a ui-sref="page3({itemId: itemId})" class="button button-positive">Page 3</a>
</ion-content>
</ion-view>
</script>
<script id="page3.html" type="text/ng-template">
<ion-view title="Page 3">
<ion-content padding="true">
<h2>IITTEEEM {{itemId}}</h2>
<a ng-click="goBack()" class="button button-positive">Back</a>
<a href="#/page1" class="button button-positive">Page 1</a>
</ion-content>
</ion-view>
</script>
<script>
angular.module('nav', ['ionic'])
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
//$ionicConfigProvider.views.maxCache(0);
$stateProvider
.state('page1', {
url: "/page1",
templateUrl: "page1.html",
controller: 'Page1Ctrl'
})
.state('page2', {
url: "/page2/:itemId",
templateUrl: "page2.html",
controller: 'Page2Ctrl'
})
.state('page3', {
url: "/page3/:itemId",
templateUrl: "page3.html",
controller: 'Page3Ctrl'
})
$urlRouterProvider.otherwise("/page1");
})
.controller('Page1Ctrl', function($scope, $ionicHistory) {
$scope.random = Math.random() * 100;
$scope.items = [];
for(var i = 0; i < 4; i++) {
$scope.items.push({ id: i });
}
$scope.items2 = [];
for(var i = 0; i < 4; i++) {
$scope.items2.push({id: i});
}
})
.controller('Page2Ctrl', function($timeout, $scope, $ionicNavBarDelegate, $ionicHistory, $stateParams) {
console.log('Page 2 params', $stateParams);
$scope.itemId = $stateParams.itemId;
$scope.goBack = function() {
$ionicNavBarDelegate.back();
};
})
.controller('Page3Ctrl', function($scope, $ionicNavBarDelegate, $stateParams) {
console.log('State params 3', $stateParams);
$scope.itemId = $stateParams.itemId;
$scope.goBack = function() {
$ionicNavBarDelegate.back();
};
})
</script>
</body>
</html>