Implemented URL query parsing for initial token /opa/?token=abcde
[src/app-framework-demo.git] / afb-client / bower_components / angular-ui-router / README.md
1 # AngularUI Router  [![Build Status](https://travis-ci.org/angular-ui/ui-router.svg?branch=master)](https://travis-ci.org/angular-ui/ui-router)
2
3 #### The de-facto solution to flexible routing with nested views
4 ---
5 **[Download 0.2.17](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|**
6 **[Guide](https://github.com/angular-ui/ui-router/wiki) |**
7 **[API](http://angular-ui.github.io/ui-router/site) |**
8 **[Sample](http://angular-ui.github.com/ui-router/sample/) ([Src](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) |**
9 **[FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) |**
10 **[Resources](#resources) |**
11 **[Report an Issue](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#report-an-issue) |**
12 **[Contribute](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#contribute) |**
13 **[Help!](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router) |**
14 **[Discuss](https://groups.google.com/forum/#!categories/angular-ui/router)**
15
16 ---
17
18 *_Please help us out by testing the 1.0 alpha release!_* 
19
20 [1.0.0alpha0 Announcement](https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0) ([Source  Code](https://github.com/angular-ui/ui-router/tree/feature-1.0)) | [Sample App](http://ui-router.github.io/sample-app/) ([Source Code](https://github.com/ui-router/sample-app)) | [Known Issues](https://github.com/angular-ui/ui-router/issues?q=is%3Aissue+is%3Aopen+label%3A1.0)
21
22
23 ---
24
25 AngularUI Router is a routing framework for [AngularJS](http://angularjs.org), which allows you to organize the
26 parts of your interface into a [*state machine*](https://en.wikipedia.org/wiki/Finite-state_machine). Unlike the
27 [`$route` service](http://docs.angularjs.org/api/ngRoute.$route) in the Angular ngRoute module, which is organized around URL
28 routes, UI-Router is organized around [*states*](https://github.com/angular-ui/ui-router/wiki),
29 which may optionally have routes, as well as other behavior, attached.
30
31 States are bound to *named*, *nested* and *parallel views*, allowing you to powerfully manage your application's interface.
32
33 Check out the sample app: http://angular-ui.github.io/ui-router/sample/
34
35 -
36 **Note:** *UI-Router is under active development. As such, while this library is well-tested, the API may change. Consider using it in production applications only if you're comfortable following a changelog and updating your usage accordingly.*
37
38
39 ## Get Started
40
41 **(1)** Get UI-Router in one of the following ways:
42  - clone & [build](CONTRIBUTING.md#developing) this repository
43  - [download the release](http://angular-ui.github.io/ui-router/release/angular-ui-router.js) (or [minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js))
44  - [link to cdn](http://cdnjs.com/libraries/angular-ui-router)
45  - via **[jspm](http://jspm.io/)**: by running `$ jspm install angular-ui-router` from your console
46  - or via **[npm](https://www.npmjs.org/)**: by running `$ npm install angular-ui-router` from your console
47  - or via **[Bower](http://bower.io/)**: by running `$ bower install angular-ui-router` from your console
48  - or via **[Component](https://github.com/component/component)**: by running `$ component install angular-ui/ui-router` from your console
49
50 **(2)** Include `angular-ui-router.js` (or `angular-ui-router.min.js`) in your `index.html`, after including Angular itself (For Component users: ignore this step)
51
52 **(3)** Add `'ui.router'` to your main module's list of dependencies (For Component users: replace `'ui.router'` with `require('angular-ui-router')`)
53
54 When you're done, your setup should look similar to the following:
55
56 >
57 ```html
58 <!doctype html>
59 <html ng-app="myApp">
60 <head>
61     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
62     <script src="js/angular-ui-router.min.js"></script>
63     <script>
64         var myApp = angular.module('myApp', ['ui.router']);
65         // For Component users, it should look like this:
66         // var myApp = angular.module('myApp', [require('angular-ui-router')]);
67     </script>
68     ...
69 </head>
70 <body>
71     ...
72 </body>
73 </html>
74 ```
75
76 ### [Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)
77
78 The majority of UI-Router's power is in its ability to nest states & views.
79
80 **(1)** First, follow the [setup](#get-started) instructions detailed above.
81
82 **(2)** Then, add a [`ui-view` directive](https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view) to the `<body />` of your app.
83
84 >
85 ```html
86 <!-- index.html -->
87 <body>
88     <div ui-view></div>
89     <!-- We'll also add some navigation: -->
90     <a ui-sref="state1">State 1</a>
91     <a ui-sref="state2">State 2</a>
92 </body>
93 ```
94
95 **(3)** You'll notice we also added some links with [`ui-sref` directives](https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-sref). In addition to managing state transitions, this directive auto-generates the `href` attribute of the `<a />` element it's attached to, if the corresponding state has a URL. Next we'll add some templates. These will plug into the `ui-view` within `index.html`. Notice that they have their own `ui-view` as well! That is the key to nesting states and views.
96
97 >
98 ```html
99 <!-- partials/state1.html -->
100 <h1>State 1</h1>
101 <hr/>
102 <a ui-sref="state1.list">Show List</a>
103 <div ui-view></div>
104 ```
105 ```html
106 <!-- partials/state2.html -->
107 <h1>State 2</h1>
108 <hr/>
109 <a ui-sref="state2.list">Show List</a>
110 <div ui-view></div>
111 ```
112
113 **(4)** Next, we'll add some child templates. *These* will get plugged into the `ui-view` of their parent state templates.
114
115 >
116 ```html
117 <!-- partials/state1.list.html -->
118 <h3>List of State 1 Items</h3>
119 <ul>
120   <li ng-repeat="item in items">{{ item }}</li>
121 </ul>
122 ```
123
124 >
125 ```html
126 <!-- partials/state2.list.html -->
127 <h3>List of State 2 Things</h3>
128 <ul>
129   <li ng-repeat="thing in things">{{ thing }}</li>
130 </ul>
131 ```
132
133 **(5)** Finally, we'll wire it all up with `$stateProvider`. Set up your states in the module config, as in the following:
134
135
136 >
137 ```javascript
138 myApp.config(function($stateProvider, $urlRouterProvider) {
139   //
140   // For any unmatched url, redirect to /state1
141   $urlRouterProvider.otherwise("/state1");
142   //
143   // Now set up the states
144   $stateProvider
145     .state('state1', {
146       url: "/state1",
147       templateUrl: "partials/state1.html"
148     })
149     .state('state1.list', {
150       url: "/list",
151       templateUrl: "partials/state1.list.html",
152       controller: function($scope) {
153         $scope.items = ["A", "List", "Of", "Items"];
154       }
155     })
156     .state('state2', {
157       url: "/state2",
158       templateUrl: "partials/state2.html"
159     })
160     .state('state2.list', {
161       url: "/list",
162       templateUrl: "partials/state2.list.html",
163       controller: function($scope) {
164         $scope.things = ["A", "Set", "Of", "Things"];
165       }
166     });
167 });
168 ```
169
170 **(6)** See this quick start example in action.
171 >**[Go to Quick Start Plunker for Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)**
172
173 **(7)** This only scratches the surface
174 >**[Dive Deeper!](https://github.com/angular-ui/ui-router/wiki)**
175
176
177 ### [Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview)
178
179 Another great feature is the ability to have multiple `ui-view`s view per template.
180
181 **Pro Tip:** *While multiple parallel views are a powerful feature, you'll often be able to manage your
182 interfaces more effectively by nesting your views, and pairing those views with nested states.*
183
184 **(1)** Follow the [setup](#get-started) instructions detailed above.
185
186 **(2)** Add one or more `ui-view` to your app, give them names.
187 >
188 ```html
189 <!-- index.html -->
190 <body>
191     <div ui-view="viewA"></div>
192     <div ui-view="viewB"></div>
193     <!-- Also a way to navigate -->
194     <a ui-sref="route1">Route 1</a>
195     <a ui-sref="route2">Route 2</a>
196 </body>
197 ```
198
199 **(3)** Set up your states in the module config:
200 >
201 ```javascript
202 myApp.config(function($stateProvider) {
203   $stateProvider
204     .state('index', {
205       url: "",
206       views: {
207         "viewA": { template: "index.viewA" },
208         "viewB": { template: "index.viewB" }
209       }
210     })
211     .state('route1', {
212       url: "/route1",
213       views: {
214         "viewA": { template: "route1.viewA" },
215         "viewB": { template: "route1.viewB" }
216       }
217     })
218     .state('route2', {
219       url: "/route2",
220       views: {
221         "viewA": { template: "route2.viewA" },
222         "viewB": { template: "route2.viewB" }
223       }
224     })
225 });
226 ```
227
228 **(4)** See this quick start example in action.
229 >**[Go to Quick Start Plunker for Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview)**
230
231
232 ## Resources
233
234 * [In-Depth Guide](https://github.com/angular-ui/ui-router/wiki)
235 * [API Reference](http://angular-ui.github.io/ui-router/site)
236 * [Sample App](http://angular-ui.github.com/ui-router/sample/) ([Source](https://github.com/angular-ui/ui-router/tree/gh-pages/sample))
237 * [FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions)
238 * [Slides comparing ngRoute to ui-router](http://slid.es/timkindberg/ui-router#/)
239 * [UI-Router Extras / Addons](http://christopherthielen.github.io/ui-router-extras/#/home) (@christopherthielen)
240  
241 ### Videos
242
243 * [Introduction Video](https://egghead.io/lessons/angularjs-introduction-ui-router) (egghead.io)
244 * [Tim Kindberg on Angular UI-Router](https://www.youtube.com/watch?v=lBqiZSemrqg)
245 * [Activating States](https://egghead.io/lessons/angularjs-ui-router-activating-states) (egghead.io)
246 * [Learn Angular.js using UI-Router](http://youtu.be/QETUuZ27N0w) (LearnCode.academy)
247
248
249
250 ## Reporting issues and Contributing
251
252 Please read our [Contributor guidelines](CONTRIBUTING.md) before reporting an issue or creating a pull request.