Permalink
Fetching contributors…
Cannot retrieve contributors at this time
446 lines (443 sloc) 21.3 KB
---
---
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ng2ViewDeclaration | UI-Router</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/typedoctheme.css">
<script src="../assets/js/modernizr.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">UI-Router</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">Externals</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="../globals.html">Globals</a>
</li>
<li>
<a href="../modules/ng2.html">ng2</a>
</li>
<li>
<a href="ng2.ng2viewdeclaration.html">Ng2ViewDeclaration</a>
</li>
</ul>
<h1>Interface Ng2ViewDeclaration</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="tsd-signature-type">_ViewDeclaration</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="ng2.ng2viewdeclaration.html#bindings" class="tsd-kind-icon">bindings</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="ng2.ng2viewdeclaration.html#component" class="tsd-kind-icon">component</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="bindings" class="tsd-anchor"></a>
<!---->
<!--<h3><span class="tsd-flag ts-flagOptional">Optional</span> bindings</h3>-->
<!---->
<div class="tsd-signature tsd-kind-icon">bindings<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span> <div class="tsd-header">
<p> An object which maps <code>resolve</code> keys to <a href="ng2.ng2viewdeclaration.html#component">component</a> <code>bindings</code>. </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>An object which maps <code>resolve</code> keys to <a href="ng2.ng2viewdeclaration.html#component">component</a> <code>bindings</code>.</p>
</div>
<p>A property of <a href="ng2.ng2statedeclaration.html">Ng2StateDeclaration</a> or <a href="ng2.ng2viewdeclaration.html">Ng2ViewDeclaration</a>:</p>
<p>When using a <a href="ng2.ng2viewdeclaration.html#component">component</a> declaration (<code>component: MyComponent</code>), each input binding for the component is supplied
data from a resolve of the same name, by default. You may supply data from a different resolve name by mapping it here.</p>
<p>Each key in this object is the name of one of the component&#39;s input bindings.
Each value is the name of the resolve that should be provided to that binding.</p>
<p>Any component bindings that are omitted from this map get the default behavior of mapping to a resolve of the
same name.</p>
<dl class="tsd-comment-tags">
<dt>example</dt>
<dd><pre><code class="lang-js">
$stateProvider.state(<span class="hljs-string">'foo'</span>, {
resolve: {
foo: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">FooService</span>) </span>{ <span class="hljs-keyword">return</span> FooService.get(); },
bar: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">BarService</span>) </span>{ <span class="hljs-keyword">return</span> BarService.get(); }
},
component: <span class="hljs-string">'Baz'</span>,
<span class="hljs-comment">// The component's `baz` binding gets data from the `bar` resolve</span>
<span class="hljs-comment">// The component's `foo` binding gets data from the `foo` resolve (default behavior)</span>
bindings: {
baz: <span class="hljs-string">'bar'</span>
}
});
app.component(<span class="hljs-string">'Baz'</span>, {
templateUrl: <span class="hljs-string">'baz.html'</span>,
controller: <span class="hljs-string">'BazController'</span>,
bindings: {
foo: <span class="hljs-string">'&lt;'</span>, <span class="hljs-comment">// foo binding</span>
baz: <span class="hljs-string">'&lt;'</span> <span class="hljs-comment">// baz binding</span>
}
});
</code></pre>
</dd>
</dl>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/angular-ui/ui-router/blob/70a237a/src/ng2/interface.ts#L268">ng2/interface.ts:268</a></li>
</ul>
</aside>
<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">string</span></h5>
</li>
</ul>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="component" class="tsd-anchor"></a>
<!---->
<!--<h3><span class="tsd-flag ts-flagOptional">Optional</span> component</h3>-->
<!---->
<div class="tsd-signature tsd-kind-icon">component<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Type</span> <div class="tsd-header">
<p> The <code>Component</code> class to use for this view. </p>
</div>
</div>
<div class="tsd-declaration">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The <code>Component</code> class to use for this view.</p>
</div>
<p>A property of <a href="ng2.ng2statedeclaration.html">Ng2StateDeclaration</a> or <a href="ng2.ng2viewdeclaration.html">Ng2ViewDeclaration</a>:</p>
<h3 id="the-component-class-which-will-be-used-for-this-view-">The component class which will be used for this view.</h3>
<dl class="tsd-comment-tags">
<dt>example</dt>
<dd><pre><code class="lang-js">
.state(<span class="hljs-string">'profile'</span>, {
<span class="hljs-comment">// Use the &lt;my-profile&gt;&lt;/my-profile&gt; component for the Unnamed view</span>
component: MyProfileComponent,
}
.state(<span class="hljs-string">'messages'</span>, {
<span class="hljs-comment">// use the &lt;nav-bar&gt;&lt;/nav-bar&gt; component for the view named 'header'</span>
<span class="hljs-comment">// use the &lt;message-list&gt;&lt;/message-list&gt; component for the view named 'content'</span>
views: {
header: { component: NavBar },
content: { component: MessageList }
}
}
<span class="hljs-comment">// Named views shorthand:</span>
<span class="hljs-comment">// Inside a "views:" block, a Component class (NavBar) is shorthand for { component: NavBar }</span>
.state(<span class="hljs-string">'contacts'</span>, {
<span class="hljs-comment">// use the &lt;nav-bar&gt;&lt;/nav-bar&gt; component for the view named 'header'</span>
<span class="hljs-comment">// use the &lt;contact-list&gt;&lt;/contact-list&gt; component for the view named 'content'</span>
views: {
header: NavBar,
content: ContactList
}
}
</code></pre>
<h3 id="accessing-resolve-data">Accessing Resolve Data</h3>
<p>The component can access the Transition&#39;s <a href="ng2.ng2statedeclaration.html#resolve">Ng2StateDeclaration.resolve</a> data in one of two ways:</p>
<p>1) Using Dependency Injection in the component constructor</p>
<p>(using Typescript)</p>
<pre><code class="lang-js"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyComponent</span> </span>{
<span class="hljs-keyword">constructor</span>(@Inject("myResolveData") public resolveValueA, resolveValueB: public SomeClass) {
}
}
</code></pre>
<p>(using ES6/7/babel)</p>
<pre><code class="lang-js"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyComponent</span> </span>{
<span class="hljs-keyword">static</span> get parameters() {
<span class="hljs-keyword">return</span> [[<span class="hljs-string">"myResolveData"</span>], [MyResolveClass]];
}
<span class="hljs-keyword">constructor</span>(resolveValueA, resolveValueB) {
<span class="hljs-keyword">this</span>.resolveValueA = resolveValueA;
<span class="hljs-keyword">this</span>.resolveValueB = resolveValueB;
}
}
</code></pre>
<p>See also: <a href="https://github.com/shuhei/babel-plugin-angular2-annotations">https://github.com/shuhei/babel-plugin-angular2-annotations</a></p>
<p>2) Using a component input</p>
<p>Note: To bind a resolve to a component input, the resolves must <code>provide:</code> a string value</p>
<p>```js</p>
</dd>
<dt>component</dt>
<dd><p>() {
inputs: [&#39;resolveValueA&#39;]
}
class MyComponent {
myResolveValueA;
@Input() resolveValueB;
@Input(&quot;resolveValueC&quot;) resolveValueC;</p>
<p> constructor() {
}
}
```</p>
</dd>
</dl>
</div>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/angular-ui/ui-router/blob/70a237a/src/ng2/interface.ts#L225">ng2/interface.ts:225</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="../globals.html"><em>Globals</em></a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/common.html">common</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/common_hof.html">common_<wbr>hof</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/common_predicates.html">common_<wbr>predicates</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/common_strings.html">common_<wbr>strings</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/core.html">core</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/hooks.html">hooks</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/justjs.html">justjs</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/ng1.html">ng1</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/ng1_directives.html">ng1_<wbr>directives</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/ng1_state_events.html">ng1_<wbr>state_<wbr>events</a>
</li>
<li class="current tsd-kind-external-module">
<a href="../modules/ng2.html">ng2</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/ng2_directives.html">ng2_<wbr>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/path.html">path</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/resolve.html">resolve</a>
</li>
<li class=" 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>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/ng2.ng2viewconfig.html" class="tsd-kind-icon">Ng2<wbr>View<wbr>Config</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/ng2.uirouterconfig.html" class="tsd-kind-icon">UIRouter<wbr>Config</a>
</li>
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="../classes/ng2.uirouterlocation.html" class="tsd-kind-icon">UIRouter<wbr>Location</a>
</li>
<li class=" tsd-kind-interface tsd-parent-kind-external-module">
<a href="ng2.ng2statedeclaration.html" class="tsd-kind-icon">Ng2<wbr>State<wbr>Declaration</a>
</li>
</ul>
<ul class="current">
<li class="current tsd-kind-interface tsd-parent-kind-external-module">
<a href="ng2.ng2viewdeclaration.html" class="tsd-kind-icon">Ng2<wbr>View<wbr>Declaration</a>
<ul>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="ng2.ng2viewdeclaration.html#bindings" class="tsd-kind-icon">bindings</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="ng2.ng2viewdeclaration.html#component" class="tsd-kind-icon">component</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-variable tsd-parent-kind-external-module">
<a href="../modules/ng2.html#uirouter_providers" class="tsd-kind-icon">UIROUTER_<wbr>PROVIDERS</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported">
<a href="../modules/ng2.html#id" class="tsd-kind-icon">id</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported">
<a href="../modules/ng2.html#splitonequals" class="tsd-kind-icon">split<wbr>OnEquals</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported">
<a href="../modules/ng2.html#splitonhash" class="tsd-kind-icon">split<wbr>OnHash</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported">
<a href="../modules/ng2.html#splitonquestionmark" class="tsd-kind-icon">split<wbr>OnQuestion<wbr>Mark</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module">
<a href="../modules/ng2.html#ng2viewsbuilder" class="tsd-kind-icon">ng2<wbr>Views<wbr>Builder</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-external-module tsd-is-not-exported">
<a href="../modules/ng2.html#uirouterfactory" class="tsd-kind-icon">ui<wbr>Router<wbr>Factory</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>