ui-router---$stateProvider
转自:http://blog.csdn.net/violet_day/article/details/17515157
$stateProvider
$stateProvider.state(stateName, stateConfig)
Creates a new application state. For alternate usage, see Object-based States
The parameters for .state() are:
stateName
String
一个唯一的状态的名称,比如‘home’,'about','contacts',创建子状态用'.',比如 "about.sales", "home.newest". Read more about nested states: Nested States & Nested Views
// The state() method takes a unique stateName (String) and a stateConfig (Object)
$stateProvider.state(stateName, stateConfig); // stateName can be a single top-level name (must be unique).
$stateProvider.state("home", {}); // Or it can be a nested state name. This state is a child of the above "home" state.
$stateProvider.state("home.newest", {}); // Nest states as deeply as needed.
$stateProvider.state("home.newest.abc.xyz.inception", {}); // state() returns $stateProvider, so you can chain state declarations.
$stateProvider.state("home", {}).state("about", {}).state("contacts", {});
stateConfig
Object
一个config的object对象接受已下属性
template, templateUrl, templateProvider
三种方式启动你的模板,三选一
template HTML标签或者返回HTML标签的函数
templateUrl URL或返回URL的函数
templateProvider 函数,返回HTML标签
Learn more about state templates
controller, controllerProvider
状态对应的控制器
controller 函数或者控制器的名称
controllerProvider 控制器提供者,动态的返回一个控制器的名称
resolve
依赖注意控制器的一个对象
resolve Object
- keys - 被注入控制器的名称
- factory - {string|function} 如果是string,则作为服务的别名,如果是函数,他的返回值将会被依赖注入,如果返回promise,他会在注入控制器之前执行
url
导航或转换到时,$
stateParams将被传递
url String
Learn more about url routing with states
params
An array of parameter names or regular expressions. Only use this within a state if you are not using
url. Otherwise you can specify your parameters within the url. When a state is navigated or
transitioned to, the $stateParams service will be populated with any parameters that were passed.
params Array
Learn more about parameters (examples are shown in url form, but they work just the same here)
views
使用视图属性来设置多个视图。如果你没有在一个state内需要多个视图这个属性是没有必要的。提示:请记住,通常嵌套的视图比平级的视图更加有用和强大。
views Object
- keys - {string} name of ui-view
- view config - {object} view configuration object can set up its own [templates] and (https://github.com/angular-ui/ui-router/wiki#the-simplest-form-of-state)
[controllers].
Learn more about multiple named views
abstract
抽象的状态永远不会被激活,但是可以提供属性以被其子状态继承。
abstract Boolean - (default is false)
Learn more about abstract states
onEnter,
onExit
进入或退出时的回调函数。Callback functions for when a state is entered and
exited. Good way to trigger an action or dispatch an event, such as
opening a
dialog.
onEnterFunction, injected including resolvesonExitFunction, injected including resolves
Learn more about state callbacks
data
data Object
Learn more about attaching custom data to states
ui-router---$stateProvider的更多相关文章
- angularjs的路由ui.router
<!-- 引入路由插件 --> <script src="vendor/angular-ui-router/release/angular-ui-router.min. ...
- AngularJS学习之 ui router
1.安装 bower install --save angular_ui-router 2.在项目主页面 index.html中添加 <div ui-view="">& ...
- 新建一个angularjs+requirejs+bootstrap+typescript+gulp+vscode+git的项目
环境 windows 10 准备工具 Visual Studio Code Node.js Git 需求 必须支持IE8 步骤开始: 执行命令行工具 mkdir Demo && cd ...
- ui-router API
ui-router API 英文不咋地感觉找个API都要找半天, 拿好不谢 http://angular-ui.github.io/ui-router/site/#/api/ui.router
- [AngularJS] AngularJS系列(2) 中级篇之路由
目录 原理 angular-route ui-router 事件 深度路由 原理 ng的route本质是监听hashchange事件. 在angular-route中 $rootScope.$on(' ...
- angular路由——ui.route
angular路由 使用案例 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- 【原创】ui.router源码解析
Angular系列文章之angular路由 路由(route),几乎所有的MVC(VM)框架都应该具有的特性,因为它是前端构建单页面应用(SPA)必不可少的组成部分. 那么,对于angular而言,它 ...
- 翻译:深入 AngularUI Router
原文地址:http://www.ng-newsletter.com/posts/angular-ui-router.html ui-router: https://angular-ui.github. ...
- 单页应用跳转ui-view,$stateProvider,$urlRouterProvider
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta charset="UTF- ...
- angular $stateProvider 路由的使用
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
随机推荐
- ibus用上搜狗拼音词库
1.下载搜狗拼音词库 wget http://hslinuxextra.googlecode.com/files/sougou-phrases-full.7z 2.用sougou-phrases-fu ...
- Codeforces Round #364 (Div. 2)C. They Are Everywhere(尺取法)
题目链接: C. They Are Everywhere time limit per test 2 seconds memory limit per test 256 megabytes input ...
- JAVA基础---面向对象
方法的重载Overload: 一个类中可以定义有相同的名字, 参数不同的多个方法. 调用时, 会根据不同的参数选择对应的方法. static: 在数据区, 可以计数,属于类,不属于对象: public ...
- HTTP缓存控制总结
引言 通过网络获取内容既缓慢,成本又高.大的相应需要在客户端和服务器之间多次往返通信,这拖延了浏览器可以使用和处理内容的时间,同时也增加了通信的成本.因此,缓存和重用以前获取到的资源的能力成为性能优化 ...
- DNS原理及其解析过程
网络通讯大部分是基于TCP/IP的,而TCP/IP是基于IP地址的,所以计算机在网络上进行通讯时只能识别如“202.96.134.133” 之类的IP地址,而不能认识域名.我们无法记住10个以上IP地 ...
- 使用node-livereload自动刷新页面
1. 安装node 2. 安装python 3. 安装connect, serve-static和node-livereload (以下都假设命令行当前目录为e:\WebSite) e:\WebSit ...
- 神经网络 Neuroph - Java Neural Network Platform Neuroph
http://neuroph.sourceforge.net/image_recognition.html https://github.com/neuroph/neuroph
- iOS平台软件开发工具(一)-新建的工程使用CocoaPods工具集成第三方框架
CocoaPods是一款集合了上千个第三方开源库的开发工具,能够大幅度的提升团队项目的开发效率,降低时间成本. 那么就看一下CocoaPods这个工具在项目中的使用体现吧. 我们马上用ASIHTTPR ...
- kafka第三篇--安装使用
说明:直接下载二进制包可省略安装过程,省略很多麻烦. 1单机 安装 安装过程,参考官网: > tar xzf kafka-<VERSION>.tgz > cd kafka-&l ...
- tableView等滚动视图滚动时收缩上下导航栏与标签栏
代码如下,今天有点忙,不想细说了,看不明白可以联系我 // // LQXViewController.m // LQXCallBackBar // // Created by 刘祺旭 on 15/4/ ...