|
1 | 1 | <!doctype html>
|
| 2 | +<!-- Our uiRouterSample module defined here --> |
2 | 3 | <html lang="en" ng-app="uiRouterSample">
|
3 | 4 | <head>
|
4 | 5 | <meta charset="utf-8">
|
5 | 6 |
|
| 7 | + <!-- using twitter bootstrap, but of course --> |
6 | 8 | <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
| 9 | + <!-- styles for ng-animate are located here --> |
7 | 10 | <link rel="stylesheet" type="text/css" href="styles.css">
|
8 | 11 |
|
| 12 | + <!-- Include both angular.js and angular-ui-router.js--> |
9 | 13 | <script src="../lib/angular-1.1.4.js"></script>
|
10 | 14 | <script src="../build/angular-ui-router.js"></script>
|
| 15 | + |
| 16 | + <!-- module.js declares the uiRouterSample module and adds items to $rootScope--> |
11 | 17 | <script src="module.js"></script>
|
| 18 | + <!-- factory.js defines a 'contacts' http service and a 'utils' global functions service --> |
12 | 19 | <script src="factory.js"></script>
|
| 20 | + <!-- state.js takes care of all the state configuration, where all the magic's at--> |
13 | 21 | <script src="states.js"></script>
|
14 | 22 |
|
15 | 23 | <!-- could easily use a custom property of the state here instead of 'name' -->
|
|
18 | 26 | <body>
|
19 | 27 | <div class="navbar navbar-fixed-top">
|
20 | 28 | <div class="navbar-inner"><div class="container">
|
| 29 | + |
| 30 | + <!-- ui-sref is a great directive for linking a state location with an anchor link. |
| 31 | + You should almost always use ui-sref instead of href on your links when you want |
| 32 | + then to navigate to a state. When this link is clicked it will take the application |
| 33 | + to the 'home' state. Behind the scenes the directive also adds the correct href attr |
| 34 | + and url. --> |
21 | 35 | <a class="brand" ui-sref="home">ui-router</a>
|
22 | 36 | <ul class="nav">
|
| 37 | + |
| 38 | + <!-- Here you can see ui-sref in action again. Also notice the use of $state.includes, which |
| 39 | + will set the links to 'active' if, for example on the first link, 'contacts' or any of |
| 40 | + its descendant states are activated. --> |
23 | 41 | <li ng-class="{ active: $state.includes('contacts') }"><a ui-sref="contacts.list">Contacts</a></li>
|
24 | 42 | <li ng-class="{ active: $state.includes('about') }"><a ui-sref="about">About</a></li>
|
25 | 43 | </ul>
|
26 |
| - <p class="navbar-text pull-right" ui-view="hint"></p> |
| 44 | + |
| 45 | + <!-- Here is a named ui-view. ui-views don't have to be named, but we'll be populate this |
| 46 | + on from various different child states and we want a name to help us target. --> |
| 47 | + <p ui-view="hint" class="navbar-text pull-right"></p> |
27 | 48 | </div></div>
|
28 | 49 | </div>
|
29 |
| - <div class="container" style="margin-top:60px" ui-view ng-animate="{enter:'fade-enter'}"></div> |
| 50 | + |
| 51 | + <!-- Here is the main ui-view (unnamed) and will be populate by its immediate children's templates |
| 52 | + unless otherwise explicitly named views are targeted. It's also employing ng-animate. --> |
| 53 | + <div ui-view class="container" style="margin-top:60px" ng-animate="{enter:'fade-enter'}"></div> |
| 54 | + |
| 55 | + |
30 | 56 | <hr>
|
31 | 57 | <pre>
|
| 58 | + <!-- Here's some values to keep an eye on in the sample in order to understand $state and $stateParams --> |
32 | 59 | $state = {{$state.current.name}}
|
33 | 60 | $stateParams = {{$stateParams}}
|
34 | 61 | $state full url = {{ $state.$current.url.source }}
|
|
0 commit comments