$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
控制器提供者,動態的返回一個控制器的名稱
resolve
依賴注意控制器的一個對象
resolve
Object
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 resolvesonExit
Function, injected including resolvesLearn more about state callbacks
data
data
Object