# AngularUI Router [![Build Status](https://travis-ci.org/angular-ui/ui-router.svg?branch=master)](https://travis-ci.org/angular-ui/ui-router)
#### The de-facto solution to flexible routing with nested views
---
**[Download 0.2.18](https://cdn.rawgit.com/angular-ui/ui-router/0.2.18/release/angular-ui-router.js)** (or **[Minified](https://cdn.rawgit.com/angular-ui/ui-router/0.2.18/release/angular-ui-router.min.js)**) **|**
**[Guide](https://github.com/angular-ui/ui-router/wiki) |**
**[API](http://angular-ui.github.io/ui-router/site) |**
**[Sample](http://angular-ui.github.com/ui-router/sample/) ([Src](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) |**
**[FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) |**
**[Resources](#resources) |**
**[Report an Issue](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#report-an-issue) |**
**[Contribute](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#contribute) |**
**[Help!](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router) |**
**[Discuss](https://groups.google.com/forum/#!categories/angular-ui/router)**
---
*_Please help us out by testing the 1.0 alpha release!_*
[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/master)) | [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)
---
AngularUI Router is a routing framework for [AngularJS](http://angularjs.org), which allows you to organize the
parts of your interface into a [*state machine*](https://en.wikipedia.org/wiki/Finite-state_machine). Unlike the
[`$route` service](http://docs.angularjs.org/api/ngRoute.$route) in the Angular ngRoute module, which is organized around URL
routes, UI-Router is organized around [*states*](https://github.com/angular-ui/ui-router/wiki),
which may optionally have routes, as well as other behavior, attached.
States are bound to *named*, *nested* and *parallel views*, allowing you to powerfully manage your application's interface.
Check out the sample app: http://angular-ui.github.io/ui-router/sample/
-
**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.*
## Get Started
**(1)** Get UI-Router in one of the following ways:
- clone & [build](CONTRIBUTING.md#developing) this repository
- [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))
- [link to cdn](http://cdnjs.com/libraries/angular-ui-router)
- via **[jspm](http://jspm.io/)**: by running `$ jspm install angular-ui-router` from your console
- or via **[npm](https://www.npmjs.org/)**: by running `$ npm install angular-ui-router` from your console
- or via **[Bower](http://bower.io/)**: by running `$ bower install angular-ui-router` from your console
- or via **[Component](https://github.com/component/component)**: by running `$ component install angular-ui/ui-router` from your console
**(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)
**(3)** Add `'ui.router'` to your main module's list of dependencies (For Component users: replace `'ui.router'` with `require('angular-ui-router')`)
When you're done, your setup should look similar to the following:
>
```html
<!doctype html>
<html ng-app="myApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<script>
var myApp = angular.module('myApp', ['ui.router']);
// For Component users, it should look like this:
// var myApp = angular.module('myApp', [require('angular-ui-router')]);
</script>
...
</head>
<body>
...
</body>
</html>
```
### [Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)
The majority of UI-Router's power is in its ability to nest states & views.
**(1)** First, follow the [setup](#get-started) instructions detailed above.
**(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.
>
```html
<!-- index.html -->
<body>
<div ui-view></div>
<!-- We'll also add some navigation: -->
<a ui-sref="state1">State 1</a>
<a ui-sref="state2">State 2</a>
</body>
```
**(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.
>
```html
<!-- partials/state1.html -->
<h1>State 1</h1>
<hr/>
<a ui-sref="state1.list">Show List</a>
<div ui-view></div>
```
```html
<!-- partials/state2.html -->
<h1>State 2</h1>
<hr/>
<a ui-sref="state2.list">Show List</a>
<div ui-view></div>
```
**(4)** Next, we'll add some child templates. *These* will get plugged into the `ui-view` of their parent state templates.
>
```html
<!-- partials/state1.list.html -->
<h3>List of State 1 Items</h3>
<ul>
<li ng-repeat="item in items">{{ item }}</li>
</ul>
```
>
```html
<!-- partials/state2.list.html -->
<h3>List of State 2 Things</h3>
<ul>
<li ng-repeat="thing in things">{{ thing }}</li>
</ul>
```
**(5)** Finally, we'll wire it all up with `$stateProvider`. Set up your states in the module config, as in the following:
>
```javascript
myApp.config(function($stateProvider, $urlRouterProvider) {
//
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/state1");
//
// Now set up the states
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
})
.state('state1.list', {
url: "/list",
templateUrl: "partials/state1.list.html",
controller: function($scope) {
$scope.items = ["A", "List", "Of", "Items"];
}
})
.state('state2', {
url: "/state2",
templateUrl: "partials/state2.html"
})
.state('state2.list', {
url: "/list",
templateUrl: "partials/state2.list.html",
controller: function($scope) {
$scope.things = ["A", "Set", "Of", "Things"];
}
});
});
```
**(6)** See this quick start example in action.
>**[Go to Quick Start Plunker for Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)**
**(7)** This only scratches the surface
>**[Dive Deeper!](https://github.com/angular-ui/ui-router/wiki)**
### [Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview)
Another great feature is the ability to have multiple `ui-view`s view per template.
**Pro Tip:** *While multiple parallel views are a powerful feature, you'll often be able to manage your
interfaces more effectively by nesting your views, and pairing those views with nested states.*
**(1)** Follow the [setup](#get-started) instructions detailed above.
**(2)** Add one or more `ui-view` to your app, give them names.
>
```html
<!-- index.html -->
<body>
<div ui-view="viewA"></div>
<div ui-view="viewB"></div>
<!-- Also a way to navigate -->
<a ui-sref="route1">Route 1</a>
<a ui-sref="route2">Route 2</a>
</body>
```
**(3)** Set up your states in the module config:
>
```javascript
myApp.config(function($st
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
学期期末网页设计作业合集分享 内容概览: 这个分享包涵了我在本学期期末完成的网页设计作业,其中包含多个关键部分,以帮助你全面了解和学习网页设计的整个流程。 HTML、CSS、JS、Vue代码:我提供了完整的网页源代码,详细简单有效 项目文件:除了代码,我还分享了整个项目的文件,包括设计稿、图标、图片等资源。这些资源对于理解项目背景和设计思路至关重要。 MD文档与操作手册:为了方便他人理解和使用我的作品,我编写了详细的操作手册和使用说明,同时提供了一份Markdown格式的文档,概述了项目的主要功能和特点。 学习笔记:在项目开发过程中,我记录了大量的学习笔记和心得体会。这些笔记不仅有助于理解项目的开发过程,还能为学习前端技术提供宝贵的参考资料。 适用人群: 这份作业合集适用于所有对网页设计、前端开发感兴趣的人,无论你是学生、初学者还是有一定经验的开发者。无论你是想学习新的技术,还是想了解一个完整的项目开发流程,这份资料都将为你提供极大的帮助。 使用建议: 按部就班地学习:建议从基础的HTML、CSS开始,逐步深入到JavaScript和Vue的学习。通过实践,逐步掌握前端开发的各项技能。 参考项目文件和笔记:项目文件和笔记提供了丰富的背景信息和开发经验。在学习的过程中,不妨参考这些资料,以帮助你更好地理解和学习。 动手实践:网页设计是一门实践性很强的技能。通过实际操作,你可以更好地掌握前端开发的各项技能,并提高自己的实践能力。
资源推荐
资源详情
资源评论
收起资源包目录
网页设计与维护大作业.zip (1224个子文件)
a 0B
artisan 2KB
random_compat.phar.pubkey.asc 488B
symfony_debug.c 7KB
web.config 914B
a.dat.copy 0B
ab.dat.copy 0B
abc.dat.copy 0B
app.css 113KB
normalize.css 7KB
base.css 5KB
angular-csp.css 343B
style.css 58B
resources.csv 96B
valid.csv 36B
empty.csv 0B
resources.dat 352B
resources.dat 3B
bar.dat 0B
a.dat 0B
abc.dat 0B
ab.dat 0B
phpunit.xml.dist 1KB
phpunit.xml.dist 930B
phpunit.xml.dist 831B
phpunit.xml.dist 821B
phpunit.xml.dist 780B
phpunit.xml.dist 775B
phpunit.xml.dist 372B
.editorconfig 311B
.env.example 491B
hiddeninput.exe 9KB
.gitattributes 61B
.gitignore 103B
.gitignore 80B
.gitignore 48B
.gitignore 34B
.gitignore 34B
.gitignore 34B
.gitignore 34B
.gitignore 34B
.gitignore 23B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 13B
.gitignore 9B
.gitignore 7B
.gitkeep 1B
.gitkeep 1B
.gitkeep 1B
angular.min.js.gzip 56KB
php_symfony_debug.h 2KB
.htaccess 553B
index.html 88B
favicon.ico 0B
MyZhihu.iml 4KB
ui-router-ng2.iml 916B
ui-router.iml 915B
MyZhihu.iml___jb_tmp___ 0B
resources.ini 10B
empty.ini 0B
ui-router-ng2.ipr 4KB
ui-router.ipr 3KB
ui-router-ng2.iws 110KB
ui-router.iws 103KB
angular.js 1.13MB
app.js 287KB
jquery.js 261KB
jquery.slim.js 209KB
angular-ui-router.js 169KB
angular.min.js 156KB
jquery.min.js 85KB
jquery.slim.min.js 68KB
sizzle.js 64KB
state.js 61KB
urlMatcherFactory.js 41KB
angular-ui-router.min.js 33KB
ajax.js 22KB
sizzle.min.js 19KB
event.js 19KB
base.js 18KB
effects.js 17KB
stateDirectives.js 15KB
urlRouter.js 15KB
manipulation.js 12KB
css.js 11KB
viewDirective.js 11KB
core.js 11KB
core.js 11KB
deferred.js 10KB
resolve.js 10KB
common.js 8KB
normalize.js 8KB
selector-native.js 6KB
offset.js 6KB
callbacks.js 5KB
共 1224 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
01红C
- 粉丝: 1644
- 资源: 1098
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功