Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1292 lines (1280 sloc) 73 KB
---
---
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>StateDeclaration | @uirouter/angular</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
<link rel="stylesheet" href="../assets/css/uirouter.css">
<script src="../assets/js/modernizr.js"></script>
<script src="../assets/js/reset.js"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">@uirouter/angular</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<!--
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
-->
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Internal UI-Router API</label>
<!--
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
-->
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../index.html">@uirouter/angular</a>
</li>
<li>
<a href="../modules/state.html">state</a>
</li>
<li>
<a href="state.statedeclaration.html">StateDeclaration</a>
</li>
</ul>
<h1>Interface StateDeclaration</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-comment">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The StateDeclaration object is used to define a state or nested state.</p>
</div>
<p>Note: Each implementation of UI-Router (for a specific framework)
extends this interface as necessary.</p>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js"><span class="hljs-comment">// StateDeclaration object</span>
<span class="hljs-keyword">var</span> foldersState = {
<span class="hljs-attr">name</span>: <span class="hljs-string">'folders'</span>,
<span class="hljs-attr">url</span>: <span class="hljs-string">'/folders'</span>,
<span class="hljs-attr">component</span>: FoldersComponent,
<span class="hljs-attr">resolve</span>: {
<span class="hljs-attr">allfolders</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">FolderService</span>) </span>{
<span class="hljs-keyword">return</span> FolderService.list();
}
},
}
registry.register(foldersState);
</code></pre>
<p>A state declaration may also be an ES6 class which implements the StateDeclaration interface
and has a <code>@State()</code> decorator</p>
<h4 id="example-">Example:</h4>
<p>```js
import { State } from &quot;@uirouter/core&quot;
import { FolderService } from &quot;../folder.service&quot;
// StateDeclaration class</p>
<dl class="tsd-comment-tags">
<dt>state</dt>
<dd><p>()
export class FoldersState implements StateDeclaration {
name: &#39;folders&#39;,
url: &#39;/folders&#39;,
component: FoldersComponent</p>
<p> @Resolve({ deps: [ FolderService ] })
allfolders(FolderService) {
return FolderService.list();
},
}</p>
<p>registry.register(FoldersState);
```</p>
</dd>
</dl>
</div>
</section>
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="target">StateDeclaration</span>
</li>
</ul>
</section>
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#__state" class="tsd-kind-icon">$$state</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#abstract" class="tsd-kind-icon">abstract</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#data" class="tsd-kind-icon">data</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#lazyload" class="tsd-kind-icon">lazy<wbr>Load</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#name" class="tsd-kind-icon">name</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#onenter" class="tsd-kind-icon">on<wbr>Enter</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#onexit" class="tsd-kind-icon">on<wbr>Exit</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#onretain" class="tsd-kind-icon">on<wbr>Retain</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#params" class="tsd-kind-icon">params</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#parent" class="tsd-kind-icon">parent</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#redirectto" class="tsd-kind-icon">redirect<wbr>To</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#reloadonsearch" class="tsd-kind-icon">reload<wbr>OnSearch</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#resolve" class="tsd-kind-icon">resolve</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#resolvepolicy" class="tsd-kind-icon">resolve<wbr>Policy</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#url" class="tsd-kind-icon">url</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="state.statedeclaration.html#views" class="tsd-kind-icon">views</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="__state" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> $$state</h3>
-->
<div class="tsd-signature tsd-kind-icon">$$state<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">function</span> <div class="tsd-header">
<p> Gets the internal State object API </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Gets the internal State object API</p>
</div>
<p>Gets the <em>internal API</em> for a registered state.</p>
<p>Note: the internal <a href="../classes/state.stateobject.html">StateObject</a> API is subject to change without notice</p>
</div>
</div>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../classes/state.stateobject.html" class="tsd-signature-type">StateObject</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-returns">
<h4 class="tsd-returns-title">Returns <a href="../classes/state.stateobject.html" class="tsd-signature-type">StateObject</a></h4>
</div>
</li>
</ul>
</li>
</ul>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L190">core/src/state/interface.ts:190</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="abstract" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> abstract</h3>
-->
<div class="tsd-signature tsd-kind-icon">abstract<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span> <div class="tsd-header">
<p> Abstract state indicator </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Abstract state indicator</p>
</div>
<p>An abstract state can never be directly activated.
Use an abstract state to provide inherited properties (url, resolve, data, etc) to children states.</p>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L155">core/src/state/interface.ts:155</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="data" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> data</h3>
-->
<div class="tsd-signature tsd-kind-icon">data<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span> <div class="tsd-header">
<p> An inherited property to store state data </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>An inherited property to store state data</p>
</div>
<p>This is a spot for you to store inherited state metadata.
Child states&#39; <code>data</code> object will prototypally inherit from their parent state.</p>
<p>This is a good spot to put metadata such as <code>requiresAuth</code>.</p>
<p>Note: because prototypal inheritance is used, changes to parent <code>data</code> objects reflect in the child <code>data</code> objects.
Care should be taken if you are using <code>hasOwnProperty</code> on the <code>data</code> object.
Properties from parent objects will return false for <code>hasOwnProperty</code>.</p>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L439">core/src/state/interface.ts:439</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="lazyload" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> lazy<wbr>Load</h3>
-->
<div class="tsd-signature tsd-kind-icon">lazy<wbr>Load<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">function</span> <div class="tsd-header">
<p> A function used to lazy load code </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A function used to lazy load code</p>
</div>
<p>The <code>lazyLoad</code> function is invoked before the state is activated.
The transition waits while the code is loading.</p>
<p>The function should load the code that is required to activate the state.
For example, it may load a component class, or some service code.
The function must retur a promise which resolves when loading is complete.</p>
<p>For example, this code lazy loads a service before the <code>abc</code> state is activated:</p>
<pre><code>.<span class="hljs-keyword">state</span>('abc', {
lazyLoad: (transition, <span class="hljs-keyword">state</span>) =&gt; System.import('./abcService')
}
</code></pre><p>The <code>abcService</code> file is imported and loaded
(it is assumed that the <code>abcService</code> file knows how to register itself as a service).</p>
<h4 id="lifecycle">Lifecycle</h4>
<ul>
<li>The <code>lazyLoad</code> function is invoked if a transition is going to enter the state.</li>
<li>The function is invoked before the transition starts (using an <code>onBefore</code> transition hook).</li>
<li>The function is only invoked once; while the <code>lazyLoad</code> function is loading code, it will not be invoked again.
For example, if the user double clicks a ui-sref, <code>lazyLoad</code> is only invoked once even though there were two transition attempts.
Instead, the existing lazy load promise is re-used.</li>
<li>When the promise resolves successfully, the <code>lazyLoad</code> property is deleted from the state declaration.</li>
<li>If the promise resolves to a <a href="state.lazyloadresult.html">LazyLoadResult</a> which has an array of <code>states</code>, those states are registered.</li>
<li><p>The original transition is retried (this time without the <code>lazyLoad</code> property present).</p>
</li>
<li><p>If the <code>lazyLoad</code> function fails, then the transition also fails.
The failed transition (and the <code>lazyLoad</code> function) could potentially be retried by the user.</p>
</li>
</ul>
<h3 id="lazy-loading-state-definitions-future-states-">Lazy loading state definitions (Future States)</h3>
<p>State definitions can also be lazy loaded.
This might be desirable when building large, multi-module applications.</p>
<p>To lazy load state definitions, a Future State should be registered as a placeholder.
When the state definitions are lazy loaded, the Future State is deregistered.</p>
<p>A future state can act as a placeholder for a single state, or for an entire module of states and substates.
A future state should have:</p>
<ul>
<li>A <code>name</code> which ends in <code>.**</code>.
A future state&#39;s <code>name</code> property acts as a wildcard <a href="../classes/core.glob.html">Glob</a>.
It matches any state name that starts with the <code>name</code> (including child states that are not yet loaded).</li>
<li>A <code>url</code> prefix.
A future state&#39;s <code>url</code> property acts as a wildcard.
UI-Router matches all paths that begin with the <code>url</code>.
It effectively appends <code>.*</code> to the internal regular expression.
When the prefix matches, the future state will begin loading.</li>
<li>A <code>lazyLoad</code> function.
This function should should return a Promise to lazy load the code for one or more <a href="state.statedeclaration.html">StateDeclaration</a> objects.
It should return a <a href="state.lazyloadresult.html">LazyLoadResult</a>.
Generally, one of the lazy loaded states should have the same name as the future state.
The new state will then <strong>replace the future state placeholder</strong> in the registry.</li>
</ul>
<h3 id="additional-resources">Additional resources</h3>
<p>For in depth information on lazy loading and Future States, see the <a href="https://ui-router.github.io/guides/lazyload">Lazy Loading Guide</a>.</p>
<h4 id="example-states-js">Example: states.js</h4>
<pre><code class="lang-js">
<span class="hljs-comment">// This child state is a lazy loaded future state</span>
<span class="hljs-comment">// The `lazyLoad` function loads the final state definition</span>
{
<span class="hljs-attr">name</span>: <span class="hljs-string">'parent.**'</span>,
<span class="hljs-attr">url</span>: <span class="hljs-string">'/parent'</span>,
<span class="hljs-attr">lazyLoad</span>: <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> System.import(<span class="hljs-string">'./lazy.states.js'</span>)
}
</code></pre>
<h4 id="example-lazy-states-js">Example: lazy.states.js</h4>
<p>This file is lazy loaded. It exports an array of states.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> {ChildComponent} <span class="hljs-keyword">from</span> <span class="hljs-string">"./child.component.js"</span>;
<span class="hljs-keyword">import</span> {ParentComponent} <span class="hljs-keyword">from</span> <span class="hljs-string">"./parent.component.js"</span>;
<span class="hljs-comment">// This fully defined state replaces the future state</span>
<span class="hljs-keyword">let</span> parentState = {
<span class="hljs-comment">// the name should match the future state</span>
name: <span class="hljs-string">'parent'</span>,
<span class="hljs-attr">url</span>: <span class="hljs-string">'/parent/:parentId'</span>,
<span class="hljs-attr">component</span>: ParentComponent,
<span class="hljs-attr">resolve</span>: {
<span class="hljs-attr">parentData</span>: <span class="hljs-function">(<span class="hljs-params">$transition$, ParentService</span>) =&gt;</span>
ParentService.get($transition$.params().parentId)
}
}
<span class="hljs-keyword">let</span> childState = {
<span class="hljs-attr">name</span>: <span class="hljs-string">'parent.child'</span>,
<span class="hljs-attr">url</span>: <span class="hljs-string">'/child/:childId'</span>,
<span class="hljs-attr">params</span>: {
<span class="hljs-attr">childId</span>: <span class="hljs-string">"default"</span>
},
<span class="hljs-attr">resolve</span>: {
<span class="hljs-attr">childData</span>: <span class="hljs-function">(<span class="hljs-params">$transition$, ChildService</span>) =&gt;</span>
ChildService.get($transition$.params().childId)
}
};
<span class="hljs-comment">// This array of states will be registered by the lazyLoad hook</span>
<span class="hljs-keyword">let</span> lazyLoadResults = {
<span class="hljs-attr">states</span>: [ parentState, childState ]
};
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> lazyLoadResults;
</code></pre>
<dl class="tsd-comment-tags">
<dt>param</dt>
<dd><p>the <a href="../classes/transition.transition-1.html">Transition</a> that is activating the future state</p>
</dd>
<dt>param</dt>
<dd><p>the <a href="state.statedeclaration.html">StateDeclaration</a> that the <code>lazyLoad</code> function is declared on</p>
</dd>
<dt>returns</dt>
<dd><p>a Promise to load the states.
Optionally, if the promise resolves to a <a href="state.lazyloadresult.html">LazyLoadResult</a>,
the states will be registered with the <a href="../classes/state.stateregistry.html">StateRegistry</a>.</p>
</dd>
</dl>
</div>
</div>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>transition<span class="tsd-signature-symbol">: </span><a href="../classes/transition.transition-1.html" class="tsd-signature-type">Transition</a>, state<span class="tsd-signature-symbol">: </span><a href="state.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="state.lazyloadresult.html" class="tsd-signature-type">LazyLoadResult</a><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>transition <a href="../classes/transition.transition-1.html" class="tsd-signature-type">Transition</a></h5>
</li>
<li>
<h5>state <a href="state.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a></h5>
</li>
</ul>
<div class="tsd-returns">
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="state.lazyloadresult.html" class="tsd-signature-type">LazyLoadResult</a><span class="tsd-signature-symbol">&gt;</span></h4>
</div>
</li>
</ul>
</li>
</ul>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L698">core/src/state/interface.ts:698</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="name" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> name</h3>
-->
<div class="tsd-signature tsd-kind-icon">name<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <div class="tsd-header">
<p> The state name (required) </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The state name (required)</p>
</div>
<p>A unique state name, e.g. <code>&quot;home&quot;</code>, <code>&quot;about&quot;</code>, <code>&quot;contacts&quot;</code>.
To create a parent/child state use a dot, e.g. <code>&quot;about.sales&quot;</code>, <code>&quot;home.newest&quot;</code>.</p>
<p>Note: [State] objects require unique names.
The name is used like an id.</p>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L147">core/src/state/interface.ts:147</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="onenter" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> on<wbr>Enter</h3>
-->
<div class="tsd-signature tsd-kind-icon">on<wbr>Enter<span class="tsd-signature-symbol">:</span> <a href="transition.transitionstatehookfn.html" class="tsd-signature-type">TransitionStateHookFn</a> <div class="tsd-header">
<p> A Transition Hook called with the state is being entered. See: <a href="transition.ihookregistry.html#onenter">IHookRegistry.onEnter</a> </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A Transition Hook called with the state is being entered. See: <a href="transition.ihookregistry.html#onenter">IHookRegistry.onEnter</a></p>
</div>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js">.state({
<span class="hljs-attr">name</span>: <span class="hljs-string">'mystate'</span>,
<span class="hljs-attr">onEnter</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">trans, state</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Entering "</span> + state.name);
}
});
</code></pre>
<p>Note: The above <code>onEnter</code> on the state declaration is effectively sugar for:</p>
<pre><code class="lang-js">transitionService.onEnter({ <span class="hljs-attr">entering</span>: <span class="hljs-string">'mystate'</span> }, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">trans, state</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Entering "</span> + state.name);
});
</code></pre>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L530">core/src/state/interface.ts:530</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="onexit" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> on<wbr>Exit</h3>
-->
<div class="tsd-signature tsd-kind-icon">on<wbr>Exit<span class="tsd-signature-symbol">:</span> <a href="transition.transitionstatehookfn.html" class="tsd-signature-type">TransitionStateHookFn</a> <div class="tsd-header">
<p> A Transition Hook called with the state is being exited. See: <a href="transition.ihookregistry.html#onexit">IHookRegistry.onExit</a> </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A Transition Hook called with the state is being exited. See: <a href="transition.ihookregistry.html#onexit">IHookRegistry.onExit</a></p>
</div>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js">.state({
<span class="hljs-attr">name</span>: <span class="hljs-string">'mystate'</span>,
<span class="hljs-attr">onExit</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">trans, state</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Leaving "</span> + state.name);
}
});
</code></pre>
<p>Note: The above <code>onRetain</code> on the state declaration is effectively sugar for:</p>
<pre><code class="lang-js">transitionService.onExit({ <span class="hljs-attr">exiting</span>: <span class="hljs-string">'mystate'</span> }, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">trans, state</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Leaving "</span> + state.name);
});
</code></pre>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L574">core/src/state/interface.ts:574</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="onretain" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> on<wbr>Retain</h3>
-->
<div class="tsd-signature tsd-kind-icon">on<wbr>Retain<span class="tsd-signature-symbol">:</span> <a href="transition.transitionstatehookfn.html" class="tsd-signature-type">TransitionStateHookFn</a> <div class="tsd-header">
<p> A <a href="transition.transitionstatehookfn.html">TransitionStateHookFn</a> called with the state is being retained/kept. See: <a href="transition.ihookregistry.html#onretain">IHookRegistry.onRetain</a> </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A <a href="transition.transitionstatehookfn.html">TransitionStateHookFn</a> called with the state is being retained/kept. See: <a href="transition.ihookregistry.html#onretain">IHookRegistry.onRetain</a></p>
</div>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js">.state({
<span class="hljs-attr">name</span>: <span class="hljs-string">'mystate'</span>,
<span class="hljs-attr">onRetain</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">trans, state</span>) </span>{
<span class="hljs-built_in">console</span>.log(state.name + <span class="hljs-string">" is still active!"</span>);
}
});
</code></pre>
<p>Note: The above <code>onRetain</code> on the state declaration is effectively sugar for:</p>
<pre><code class="lang-js">transitionService.onRetain({ <span class="hljs-attr">retained</span>: <span class="hljs-string">'mystate'</span> }, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">trans, state</span>) </span>{
<span class="hljs-built_in">console</span>.log(state.name + <span class="hljs-string">" is still active!"</span>);
});
</code></pre>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L552">core/src/state/interface.ts:552</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="params" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> params</h3>
-->
<div class="tsd-signature tsd-kind-icon">params<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span> <div class="tsd-header">
<p> Params configuration </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Params configuration</p>
</div>
<p>An object which optionally configures parameters declared in the url, or defines additional non-url
parameters. For each parameter being configured, add a <a href="params.paramdeclaration.html">ParamDeclaration</a> keyed to the name of the parameter.</p>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js">params: {
<span class="hljs-attr">param1</span>: {
<span class="hljs-attr">type</span>: <span class="hljs-string">"int"</span>,
<span class="hljs-attr">array</span>: <span class="hljs-literal">true</span>,
<span class="hljs-attr">value</span>: []
},
<span class="hljs-attr">param2</span>: {
<span class="hljs-attr">value</span>: <span class="hljs-string">"index"</span>
}
}
</code></pre>
</div>
</div>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-index-signature">
<h5><span class="tsd-signature-symbol">[</span>key: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]: </span><span class="tsd-signature-type">any</span></h5>
</li>
</ul>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L378">core/src/state/interface.ts:378</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="parent" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> parent</h3>
-->
<div class="tsd-signature tsd-kind-icon">parent<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><a href="state.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a> <div class="tsd-header">
<p> The parent state </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The parent state</p>
</div>
<p>Normally, a state&#39;s parent is implied from the state&#39;s <a href="state.statedeclaration.html#name">name</a>, e.g., <code>&quot;parentstate.childstate&quot;</code>.</p>
<p>Alternatively, you can explicitly set the parent state using this property.
This allows shorter state names, e.g., <code>&lt;a ui-sref=&quot;childstate&quot;&gt;Child&lt;/a&gt;</code>
instead of `<a ui-sref="parentstate.childstate">Child</a></p>
<p>When using this property, the state&#39;s name should not have any dots in it.</p>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> parentstate = {
<span class="hljs-attr">name</span>: <span class="hljs-string">'parentstate'</span>
}
<span class="hljs-keyword">var</span> childstate = {
<span class="hljs-attr">name</span>: <span class="hljs-string">'childstate'</span>,
<span class="hljs-attr">parent</span>: <span class="hljs-string">'parentstate'</span>
<span class="hljs-comment">// or use a JS var which is the parent StateDeclaration, i.e.:</span>
<span class="hljs-comment">// parent: parentstate</span>
}
</code></pre>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L181">core/src/state/interface.ts:181</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="redirectto" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> redirect<wbr>To</h3>
-->
<div class="tsd-signature tsd-kind-icon">redirect<wbr>To<span class="tsd-signature-symbol">:</span> <a href="../modules/state.html#redirecttoresult" class="tsd-signature-type">RedirectToResult</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">function</span> <div class="tsd-header">
<p> Synchronously or asynchronously redirects Transitions to a different state/params </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Synchronously or asynchronously redirects Transitions to a different state/params</p>
</div>
<p>If this property is defined, a Transition directly to this state will be redirected based on the property&#39;s value.</p>
<ul>
<li><p>If the value is a <code>string</code>, the Transition is redirected to the state named by the string.</p>
</li>
<li><p>If the property is an object with a <code>state</code> and/or <code>params</code> property,
the Transition is redirected to the named <code>state</code> and/or <code>params</code>.</p>
</li>
<li><p>If the value is a <a href="../classes/state.targetstate.html">TargetState</a> the Transition is redirected to the <code>TargetState</code></p>
</li>
<li><p>If the property is a function:</p>
<ul>
<li>The function is called with the current <a href="../classes/transition.transition-1.html">Transition</a></li>
<li>The return value is processed using the previously mentioned rules.</li>
<li>If the return value is a promise, the promise is waited for, then the resolved async value is processed using the same rules.</li>
</ul>
</li>
</ul>
<p>Note: <code>redirectTo</code> is processed as an <code>onStart</code> hook, before <code>LAZY</code> resolves.
If your redirect function relies on resolve data, get the <a href="../classes/transition.transition-1.html#injector">Transition.injector</a> and get a
promise for the resolve data using <a href="core.uiinjector.html#getasync">UIInjector.getAsync</a>.</p>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js"><span class="hljs-comment">// a string</span>
.state(<span class="hljs-string">'A'</span>, {
<span class="hljs-attr">redirectTo</span>: <span class="hljs-string">'A.B'</span>
})
<span class="hljs-comment">// a {state, params} object</span>
.state(<span class="hljs-string">'C'</span>, {
<span class="hljs-attr">redirectTo</span>: { <span class="hljs-attr">state</span>: <span class="hljs-string">'C.D'</span>, <span class="hljs-attr">params</span>: { <span class="hljs-attr">foo</span>: <span class="hljs-string">'index'</span> } }
})
<span class="hljs-comment">// a fn</span>
.state(<span class="hljs-string">'E'</span>, {
<span class="hljs-attr">redirectTo</span>: <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> <span class="hljs-string">"A"</span>
})
<span class="hljs-comment">// a fn conditionally returning a {state, params}</span>
.state(<span class="hljs-string">'F'</span>, {
<span class="hljs-attr">redirectTo</span>: <span class="hljs-function">(<span class="hljs-params">trans</span>) =&gt;</span> {
<span class="hljs-keyword">if</span> (trans.params().foo &lt; <span class="hljs-number">10</span>)
<span class="hljs-keyword">return</span> { <span class="hljs-attr">state</span>: <span class="hljs-string">'F'</span>, <span class="hljs-attr">params</span>: { <span class="hljs-attr">foo</span>: <span class="hljs-number">10</span> } };
}
})
<span class="hljs-comment">// a fn returning a promise for a redirect</span>
.state(<span class="hljs-string">'G'</span>, {
<span class="hljs-attr">redirectTo</span>: <span class="hljs-function">(<span class="hljs-params">trans</span>) =&gt;</span> {
<span class="hljs-keyword">let</span> svc = trans.injector().get(<span class="hljs-string">'SomeAsyncService'</span>)
<span class="hljs-keyword">let</span> promise = svc.getAsyncRedirectTo(trans.params.foo);
<span class="hljs-keyword">return</span> promise;
}
})
<span class="hljs-comment">// a fn that fetches resolve data</span>
.state(<span class="hljs-string">'G'</span>, {
<span class="hljs-attr">redirectTo</span>: <span class="hljs-function">(<span class="hljs-params">trans</span>) =&gt;</span> {
<span class="hljs-comment">// getAsync tells the resolve to load</span>
<span class="hljs-keyword">let</span> resolvePromise = trans.injector().getAsync(<span class="hljs-string">'SomeResolve'</span>)
<span class="hljs-keyword">return</span> resolvePromise.then(<span class="hljs-function"><span class="hljs-params">resolveData</span> =&gt;</span> resolveData === <span class="hljs-string">'login'</span> ? <span class="hljs-string">'login'</span> : <span class="hljs-literal">null</span>);
}
})
</code></pre>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L506">core/src/state/interface.ts:506</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="reloadonsearch" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> reload<wbr>OnSearch</h3>
-->
<div class="tsd-signature tsd-kind-icon">reload<wbr>OnSearch<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<dl class="tsd-comment-tags">
<dt>deprecated</dt>
<dd><p>define individual parameters as <a href="params.paramdeclaration.html#dynamic">ParamDeclaration.dynamic</a></p>
</dd>
</dl>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L703">core/src/state/interface.ts:703</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="resolve" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> resolve</h3>
-->
<div class="tsd-signature tsd-kind-icon">resolve<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><a href="../classes/resolve.resolvable.html" class="tsd-signature-type">Resolvable</a><span class="tsd-signature-symbol"> | </span><a href="resolve.resolvableliteral.html" class="tsd-signature-type">ResolvableLiteral</a><span class="tsd-signature-symbol"> | </span><a href="resolve.providerlike.html" class="tsd-signature-type">ProviderLike</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">object</span> <div class="tsd-header">
<p> Resolve - a mechanism to asynchronously fetch data, participating in the Transition lifecycle </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Resolve - a mechanism to asynchronously fetch data, participating in the Transition lifecycle</p>
</div>
<p>The <code>resolve:</code> property defines data (or other dependencies) to be fetched asynchronously when the state is being entered.
After the data is fetched, it may be used in views, transition hooks or other resolves that belong to this state.
The data may also be used in any views or resolves that belong to nested states.</p>
<h3 id="as-an-array">As an array</h3>
<p>Each array element should be a <a href="resolve.resolvableliteral.html">ResolvableLiteral</a> object.</p>
<h4 id="example-">Example:</h4>
<p>The <code>user</code> resolve injects the current <code>Transition</code> and the <code>UserService</code> (using its token, which is a string).
The [[ResolvableLiteral.resolvePolicy]] sets how the resolve is processed.
The <code>user</code> data, fetched asynchronously, can then be used in a view.</p>
<pre><code class="lang-js">var state = {
name: 'user',
url: '/user/:userId
resolve: [
{
token: 'user',
policy: { when: 'EAGER' },
deps: ['UserService', Transition],
resolveFn: (userSvc, trans) =&gt; userSvc.fetchUser(trans.params().userId) },
}
]
}
</code></pre>
<p>Note: an Angular 2 style <a href="https://angular.io/docs/ts/latest/cookbook/dependency-injection.html#!#provide"><code>useFactory</code> provider literal</a>
may also be used. See <a href="resolve.providerlike.html">ProviderLike</a>.</p>
<h4 id="example-">Example:</h4>
<pre><code><span class="hljs-string">resolve:</span> [
{ <span class="hljs-string">provide:</span> <span class="hljs-string">'token'</span>, <span class="hljs-string">useFactory:</span> (http) =&gt; http.get(<span class="hljs-string">'/'</span>), <span class="hljs-string">deps:</span> [ Http ] },
]
</code></pre><h3 id="as-an-object">As an object</h3>
<p>The <code>resolve</code> property may be an object where:</p>
<ul>
<li>Each key (string) is the name of the dependency.</li>
<li>Each value (function) is an injectable function which returns the dependency, or a promise for the dependency.</li>
</ul>
<p>This style is based on AngularJS injectable functions, but can be used with any UI-Router implementation.
If your code will be minified, the function should be <a href="https://docs.angularjs.org/guide/di#dependency-annotation">&quot;annotated&quot; in the AngularJS manner</a>.</p>
<h4 id="angularjs-example-">AngularJS Example:</h4>
<pre><code class="lang-js">resolve: {
<span class="hljs-comment">// If you inject `myStateDependency` into a controller, you'll get "abc"</span>
myStateDependency: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-string">"abc"</span>;
},
<span class="hljs-comment">// Dependencies are annotated in "Inline Array Annotation"</span>
myAsyncData: [<span class="hljs-string">'$http'</span>, <span class="hljs-string">'$transition$'</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">$http, $transition$</span>) </span>{
<span class="hljs-comment">// Return a promise (async) for the data</span>
<span class="hljs-keyword">return</span> $http.get(<span class="hljs-string">"/foos/"</span> + $transition$.params().foo);
}]
}
</code></pre>
<p>Note: You cannot specify a policy for each Resolvable, nor can you use non-string
tokens when using the object style <code>resolve:</code> block.</p>
<h3 id="lifecycle">Lifecycle</h3>
<p>Since a resolve function can return a promise, the router will delay entering the state until the promises are ready.
If any of the promises are rejected, the Transition is aborted with an Error.</p>
<p>By default, resolves for a state are fetched just before that state is entered.
Note that only states which are being <em>entered</em> during the <code>Transition</code> have their resolves fetched.
States that are &quot;retained&quot; do not have their resolves re-fetched.</p>
<p>If you are currently in a parent state <code>parent</code> and are transitioning to a child state <code>parent.child</code>, the
previously resolved data for state <code>parent</code> can be injected into <code>parent.child</code> without delay.</p>
<p>Any resolved data for <code>parent.child</code> is retained until <code>parent.child</code> is exited, e.g., by transitioning back to the <code>parent</code> state.</p>
<p>Because of this scoping and lifecycle, resolves are a great place to fetch your application&#39;s primary data.</p>
<h3 id="injecting-resolves-into-other-things">Injecting resolves into other things</h3>
<p>During a transition, Resolve data can be injected into:</p>
<ul>
<li>Views (the components which fill a <code>ui-view</code> tag)</li>
<li>Transition Hooks</li>
<li>Other resolves (a resolve may depend on asynchronous data from a different resolve)</li>
</ul>
<h3 id="injecting-other-things-into-resolves">Injecting other things into resolves</h3>
<p>Resolve functions usually have dependencies on some other API(s).
The dependencies are usually declared and injected into the resolve function.
A common pattern is to inject a custom service such as <code>UserService</code>.
The resolve then delegates to a service method, such as <code>UserService.list()</code>;</p>
<h4 id="special-injectable-tokens">Special injectable tokens</h4>
<ul>
<li><code>UIRouter</code>: The <a href="../classes/core.uirouter.html">UIRouter</a> instance which has references to all the UI-Router services.</li>
<li><code>Transition</code>: The current <a href="../classes/transition.transition-1.html">Transition</a> object; information and API about the current transition, such as
&quot;to&quot; and &quot;from&quot; State Parameters and transition options.</li>
<li><code>&#39;$transition$&#39;</code>: A string alias for the <code>Transition</code> injectable</li>
<li><code>&#39;$state$&#39;</code>: For <code>onEnter</code>/<code>onExit</code>/<code>onRetain</code>, the state being entered/exited/retained.</li>
<li>Other resolve tokens: A resolve can depend on another resolve, either from the same state, or from any parent state.</li>
</ul>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js"><span class="hljs-comment">// Injecting a resolve into another resolve</span>
resolve: [
<span class="hljs-comment">// Define a resolve 'allusers' which delegates to the UserService.list()</span>
<span class="hljs-comment">// which returns a promise (async) for all the users</span>
{ <span class="hljs-attr">provide</span>: <span class="hljs-string">'allusers'</span>, <span class="hljs-attr">useFactory</span>: <span class="hljs-function">(<span class="hljs-params">UserService</span>) =&gt;</span> UserService.list(), <span class="hljs-attr">deps</span>: [UserService] },
<span class="hljs-comment">// Define a resolve 'user' which depends on the allusers resolve.</span>
<span class="hljs-comment">// This resolve function is not called until 'allusers' is ready.</span>
{ <span class="hljs-attr">provide</span>: <span class="hljs-string">'user'</span>, (allusers, trans) =&gt; _.find(allusers, trans.params().userId, <span class="hljs-attr">deps</span>: [<span class="hljs-string">'allusers'</span>, Transition] }
}
</code></pre>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L312">core/src/state/interface.ts:312</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="resolvepolicy" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> resolve<wbr>Policy</h3>
-->
<div class="tsd-signature tsd-kind-icon">resolve<wbr>Policy<span class="tsd-signature-symbol">:</span> <a href="resolve.resolvepolicy.html" class="tsd-signature-type">ResolvePolicy</a> <div class="tsd-header">
<p> Sets the resolve policy defaults for all resolves on this state </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Sets the resolve policy defaults for all resolves on this state</p>
</div>
<p>This should be an <a href="resolve.resolvepolicy.html">ResolvePolicy</a> object.</p>
<p>It can contain the following optional keys/values:</p>
<ul>
<li><code>when</code>: (optional) defines when the resolve is fetched. Accepted values: &quot;LAZY&quot; or &quot;EAGER&quot;</li>
<li><code>async</code>: (optional) if the transition waits for the resolve. Accepted values: &quot;WAIT&quot;, &quot;NOWAIT&quot;, &quot;RXWAIT&quot;</li>
</ul>
<p>See <a href="resolve.resolvepolicy.html">ResolvePolicy</a> for more details.</p>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L326">core/src/state/interface.ts:326</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="url" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> url</h3>
-->
<div class="tsd-signature tsd-kind-icon">url<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <div class="tsd-header">
<p> The url fragment for the state </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The url fragment for the state</p>
</div>
<p>A URL fragment (with optional parameters) which is used to match the browser location with this state.</p>
<p>This fragment will be appended to the parent state&#39;s URL in order to build up the overall URL for this state.
See <a href="../classes/url.urlmatcher.html">UrlMatcher</a> for details on acceptable patterns.</p>
<dl class="tsd-comment-tags">
<dt>examples</dt>
<dd><pre><code class="lang-js">
url: <span class="hljs-string">"/home"</span>
<span class="hljs-comment">// Define a parameter named 'userid'</span>
url: <span class="hljs-string">"/users/:userid"</span>
<span class="hljs-comment">// param 'bookid' has a custom regexp</span>
url: <span class="hljs-string">"/books/{bookid:[a-zA-Z_-]}"</span>
<span class="hljs-comment">// param 'categoryid' is of type 'int'</span>
url: <span class="hljs-string">"/books/{categoryid:int}"</span>
<span class="hljs-comment">// two parameters for this state</span>
url: <span class="hljs-string">"/books/{publishername:string}/{categoryid:int}"</span>
<span class="hljs-comment">// Query parameters</span>
url: <span class="hljs-string">"/messages?before&amp;after"</span>
<span class="hljs-comment">// Query parameters of type 'date'</span>
url: <span class="hljs-string">"/messages?{before:date}&amp;{after:date}"</span>
<span class="hljs-comment">// Path and query parameters</span>
url: <span class="hljs-string">"/messages/:mailboxid?{before:date}&amp;{after:date}"</span>
</code></pre>
</dd>
</dl>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L356">core/src/state/interface.ts:356</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="views" class="tsd-anchor"></a>
<!--
<h3><span class="tsd-flag ts-flagOptional">Optional</span> views</h3>
-->
<div class="tsd-signature tsd-kind-icon">views<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span> <div class="tsd-header">
<p> Named views </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Named views</p>
</div>
<p>An optional object which defines multiple views, or explicitly targets specific named ui-views.</p>
<ul>
<li>What is a view config</li>
<li>What is a ui-view</li>
<li>Shorthand controller/template</li>
<li><p>Incompatible with ^</p>
<p>Examples:</p>
<p>Targets three named ui-views in the parent state&#39;s template</p>
</li>
</ul>
<h4 id="example-">Example:</h4>
<pre><code class="lang-js">views: {
<span class="hljs-attr">header</span>: {
<span class="hljs-attr">controller</span>: <span class="hljs-string">"headerCtrl"</span>,
<span class="hljs-attr">templateUrl</span>: <span class="hljs-string">"header.html"</span>
}, <span class="hljs-attr">body</span>: {
<span class="hljs-attr">controller</span>: <span class="hljs-string">"bodyCtrl"</span>,
<span class="hljs-attr">templateUrl</span>: <span class="hljs-string">"body.html"</span>
}, <span class="hljs-attr">footer</span>: {
<span class="hljs-attr">controller</span>: <span class="hljs-string">"footCtrl"</span>,
<span class="hljs-attr">templateUrl</span>: <span class="hljs-string">"footer.html"</span>
}
}
</code></pre>
<dl class="tsd-comment-tags">
<dt>example</dt>
<dd><pre><code class="lang-js"><span class="hljs-comment">// Targets named ui-view="header" from ancestor state 'top''s template, and</span>
<span class="hljs-comment">// named `ui-view="body" from parent state's template.</span>
views: {
<span class="hljs-string">'header@top'</span>: {
<span class="hljs-attr">controller</span>: <span class="hljs-string">"msgHeaderCtrl"</span>,
<span class="hljs-attr">templateUrl</span>: <span class="hljs-string">"msgHeader.html"</span>
}, <span class="hljs-string">'body'</span>: {
<span class="hljs-attr">controller</span>: <span class="hljs-string">"messagesCtrl"</span>,
<span class="hljs-attr">templateUrl</span>: <span class="hljs-string">"messages.html"</span>
}
}
</code></pre>
</dd>
</dl>
</div>
</div>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-index-signature">
<h5><span class="tsd-signature-symbol">[</span>key: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]: </span><a href="state._viewdeclaration.html" class="tsd-signature-type">_ViewDeclaration</a></h5>
</li>
</ul>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ui-router/core/blob/c22f694/src/state/interface.ts#L425">core/src/state/interface.ts:425</a></li>
</ul>
</aside>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="../index.html"><em>@uirouter/angular</em></a>
</li>
<li class="label tsd-is-external">
<span>Public API</span>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/core.html">core</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/directives.html">directives</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/params.html">params</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/resolve.html">resolve</a>
</li>
<li class="current tsd-kind-external-module">
<a href="../modules/state.html">state</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/trace.html">trace</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/transition.html">transition</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/url.html">url</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/view.html">view</a>
</li>
<li class="label tsd-is-external">
<span>Internal UI-<wbr><wbr>Router API</span>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/common.html">common</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/common_hof.html">common_<wbr>hof</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/common_predicates.html">common_<wbr>predicates</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/common_strings.html">common_<wbr>strings</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/hooks.html">hooks</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/ng2.html">ng2</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/path.html">path</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/vanilla.html">vanilla</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/state.statebuilder.html" class="tsd-kind-icon">State<wbr>Builder</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/state.statematcher.html" class="tsd-kind-icon">State<wbr>Matcher</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/state.stateobject.html" class="tsd-kind-icon">State<wbr>Object</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/state.statequeuemanager.html" class="tsd-kind-icon">State<wbr>Queue<wbr>Manager</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/state.stateregistry.html" class="tsd-kind-icon">State<wbr>Registry</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/state.stateservice.html" class="tsd-kind-icon">State<wbr>Service</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/state.targetstate.html" class="tsd-kind-icon">Target<wbr>State</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="state.builders.html" class="tsd-kind-icon">Builders</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module">
<a href="state.hrefoptions.html" class="tsd-kind-icon">Href<wbr>Options</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="state.lazyloadresult.html" class="tsd-kind-icon">Lazy<wbr>Load<wbr>Result</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module">
<a href="state.ng2component.html" class="tsd-kind-icon">Ng2<wbr>Component</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module">
<a href="state.ng2statedeclaration.html" class="tsd-kind-icon">Ng2<wbr>State<wbr>Declaration</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module">
<a href="state.ng2viewdeclaration.html" class="tsd-kind-icon">Ng2<wbr>View<wbr>Declaration</a>
</li>
</ul>
<ul class="current">
<li class="current tsd-kind-interface tsd-parent-kind-external-module">
<a href="state.statedeclaration.html" class="tsd-kind-icon">State<wbr>Declaration</a>
<ul>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#__state" class="tsd-kind-icon">$$state</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#abstract" class="tsd-kind-icon">abstract</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#data" class="tsd-kind-icon">data</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#lazyload" class="tsd-kind-icon">lazy<wbr>Load</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#name" class="tsd-kind-icon">name</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#onenter" class="tsd-kind-icon">on<wbr>Enter</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#onexit" class="tsd-kind-icon">on<wbr>Exit</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#onretain" class="tsd-kind-icon">on<wbr>Retain</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#params" class="tsd-kind-icon">params</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#parent" class="tsd-kind-icon">parent</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#redirectto" class="tsd-kind-icon">redirect<wbr>To</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#reloadonsearch" class="tsd-kind-icon">reload<wbr>OnSearch</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#resolve" class="tsd-kind-icon">resolve</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#resolvepolicy" class="tsd-kind-icon">resolve<wbr>Policy</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#url" class="tsd-kind-icon">url</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="state.statedeclaration.html#views" class="tsd-kind-icon">views</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-interface tsd-parent-kind-external-module">
<a href="state.targetstatedef.html" class="tsd-kind-icon">Target<wbr>State<wbr>Def</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="state.transitionpromise.html" class="tsd-kind-icon">Transition<wbr>Promise</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="state._viewdeclaration.html" class="tsd-kind-icon">_<wbr>View<wbr>Declaration</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module tsd-is-external">
<a href="../modules/state.html#builderfunction" class="tsd-kind-icon">Builder<wbr>Function</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module">
<a href="../modules/state.html#oninvalidcallback" class="tsd-kind-icon">On<wbr>Invalid<wbr>Callback</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module">
<a href="../modules/state.html#redirecttoresult" class="tsd-kind-icon">Redirect<wbr>ToResult</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module">
<a href="../modules/state.html#resolvetypes" class="tsd-kind-icon">Resolve<wbr>Types</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module">
<a href="../modules/state.html#stateorname" class="tsd-kind-icon">State<wbr>OrName</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module">
<a href="../modules/state.html#stateregistrylistener" class="tsd-kind-icon">State<wbr>Registry<wbr>Listener</a>
</li>
<li class=" tsd-kind-type-alias tsd-parent-kind-external-module">
<a href="../modules/state.html#_statedeclaration" class="tsd-kind-icon">_<wbr>State<wbr>Declaration</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#databuilder" class="tsd-kind-icon">data<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#getnavigablebuilder" class="tsd-kind-icon">get<wbr>Navigable<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#getparamsbuilder" class="tsd-kind-icon">get<wbr>Params<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#geturlbuilder" class="tsd-kind-icon">get<wbr>Url<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#includesbuilder" class="tsd-kind-icon">includes<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#namebuilder" class="tsd-kind-icon">name<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#parseurl" class="tsd-kind-icon">parse<wbr>Url</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#pathbuilder" class="tsd-kind-icon">path<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external">
<a href="../modules/state.html#resolvablesbuilder" class="tsd-kind-icon">resolvables<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-external tsd-is-not-exported">
<a href="../modules/state.html#selfbuilder" class="tsd-kind-icon">self<wbr>Builder</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="http://typedoc.io" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="../assets/js/search.js"><' + '/script>');</script>
</body>
</html>
You can’t perform that action at this time.