Skip to content

Commit 33913a5

Browse files
committed
added the initial view example to the sample app
1 parent 1300fb9 commit 33913a5

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

sample/empty.content.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h3>Current initial view title:</h3>
2+
<p><input type="text" ng-model="data.initialViewTitle"></p>
3+
<p><button class="btn" ng-click="showInitialView($event)">Back</button></p>

sample/empty.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div>This view contains a nested view below:</div>
2+
<div ui-view="emptycontent">
3+
<h3>{{data.initialViewTitle}}</h3>
4+
<p><button class="btn" ng-click="changeInitialViewTitle($event)">Change</button></p>
5+
</div>

sample/index.html

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<html lang="en" ng-app="sample"><head>
33
<meta charset="utf-8">
4-
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
4+
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
55
<style type="text/css">
66
.fade-enter-setup, .fade-leave-setup {
77
transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0s;
@@ -17,7 +17,7 @@
1717
</style>
1818
<script src="../lib/angular-1.1.4.js"></script>
1919
<script src="../build/angular-ui-router.js"></script>
20-
20+
2121
<!-- could easily use a custom property of the state here instead of 'name' -->
2222
<title ng-bind="$state.current.name + ' - ui-router'">ui-router</title>
2323
</head><body>
@@ -195,6 +195,32 @@
195195
function ($timeout) {
196196
return $timeout(function () { return "Hello world" }, 100);
197197
}],
198+
})
199+
.state('empty', {
200+
url: '/empty',
201+
templateUrl: 'empty.html',
202+
controller:
203+
[ '$scope', '$state',
204+
function ($scope, $state) {
205+
// Using an object to access it via ng-model from child scope
206+
$scope.data = {
207+
initialViewTitle: "I am an initial view"
208+
}
209+
$scope.changeInitialViewTitle = function($event) {
210+
$state.transitionTo('empty.emptycontent');
211+
};
212+
$scope.showInitialView = function($event) {
213+
$state.transitionTo('empty');
214+
};
215+
}]
216+
})
217+
.state('empty.emptycontent', {
218+
url: '/content',
219+
views: {
220+
'emptycontent': {
221+
templateUrl: 'empty.content.html'
222+
}
223+
}
198224
});
199225
}])
200226
.run(

0 commit comments

Comments
 (0)