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 Statesgit

The parameters for .state() are:github

stateName

Stringexpress

一个惟一的状态的名称,好比‘home’,'about','contacts',建立子状态用'.',好比 "about.sales", "home.newest". Read more about nested states: Nested States & Nested Viewsbootstrap

// 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

Objectpromise

一个config的object对象接受已下属性app

template, templateUrl, templateProvider

三种方式启动你的模板,三选一ide

template HTML标签或者返回HTML标签的函数函数

templateUrl URL或返回URL的函数ui

templateProvider 函数,返回HTML标签this

Learn more about state templates

controller, controllerProvider

状态对应的控制器

controller 函数或者控制器的名称

controllerProvider 控制器提供者,动态的返回一个控制器的名称

Learn more about controllers

resolve

依赖注意控制器的一个对象

resolve Object

  • keys - 被注入控制器的名称
  • factory - {string|function} 若是是string,则做为服务的别名,若是是函数,他的返回值将会被依赖注入,若是返回promise,他会在注入控制器以前执行

Learn more about resolve

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

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.

  • onEnter Function, injected including resolves
  • onExit Function, injected including resolves

Learn more about state callbacks

data

任意数据对象,用于自定义配置很是有用。Arbitrary data object, useful for custom configuration.

data Object

Learn more about attaching custom data to states

相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息