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

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息