forked from mmistakes/minimal-mistakes
-
Notifications
You must be signed in to change notification settings - Fork 27
/
__uirouter_core_src_state_interface_.statedeclaration.html
1104 lines (1093 loc) · 71.5 KB
/
__uirouter_core_src_state_interface_.statedeclaration.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
---
<!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">
</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">Externals</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">@uirouter/angular</a>
</li>
<li>
<a href="../modules/__uirouter_core_src_state_interface_.html">"@uirouter/core/src/state/interface"</a>
</li>
<li>
<a href="__uirouter_core_src_state_interface_.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>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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>
</div>
</section>
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="target">StateDeclaration</span>
<ul class="tsd-hierarchy">
<li>
<a href="_interface_.ng2statedeclaration.html" class="tsd-signature-type">Ng2StateDeclaration</a>
</li>
</ul>
</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 tsd-is-external">
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#abstract" class="tsd-kind-icon">abstract</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#data" class="tsd-kind-icon">data</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#dynamic" class="tsd-kind-icon">dynamic</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#lazyload" class="tsd-kind-icon">lazy<wbr>Load</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#name" class="tsd-kind-icon">name</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#onenter" class="tsd-kind-icon">on<wbr>Enter</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#onexit" class="tsd-kind-icon">on<wbr>Exit</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#onretain" class="tsd-kind-icon">on<wbr>Retain</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#params" class="tsd-kind-icon">params</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#parent" class="tsd-kind-icon">parent</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#redirectto" class="tsd-kind-icon">redirect<wbr>To</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#reloadonsearch" class="tsd-kind-icon">reload<wbr>OnSearch</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#resolve" class="tsd-kind-icon">resolve</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#resolvepolicy" class="tsd-kind-icon">resolve<wbr>Policy</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#url" class="tsd-kind-icon">url</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="__uirouter_core_src_state_interface_.statedeclaration.html#views" class="tsd-kind-icon">views</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group tsd-is-external">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:120</li>
</ul>
</aside>
<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>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:405</li>
</ul>
</aside>
<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' <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>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a name="dynamic" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagOptional">Optional</span> dynamic</h3>
<div class="tsd-signature tsd-kind-icon">dynamic<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:676</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Marks all the state's parameters as <code>dynamic</code>.</p>
</div>
<p>All parameters on the state will use this value for <code>dynamic</code> as a default.
Individual parameters may override this default using <a href="__uirouter_core_src_params_interface_.paramdeclaration.html#dynamic">ParamDeclaration.dynamic</a> in the <a href="__uirouter_core_src_state_interface_.statedeclaration.html#params">params</a> block.</p>
<p>Note: this value overrides the <code>dynamic</code> value on a custom parameter type (<a href="__uirouter_core_src_params_interface_.paramtypedefinition.html#dynamic">ParamTypeDefinition.dynamic</a>).</p>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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-symbol">(</span>transition<span class="tsd-signature-symbol">: </span><a href="../classes/__uirouter_core_src_transition_transition_.transition.html" class="tsd-signature-type">Transition</a>, state<span class="tsd-signature-symbol">: </span><a href="__uirouter_core_src_state_interface_.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><a href="__uirouter_core_src_state_interface_.transitionpromise.html#promise" class="tsd-signature-type">Promise</a><span class="tsd-signature-symbol"><</span><a href="__uirouter_core_src_state_interface_.lazyloadresult.html" class="tsd-signature-type">LazyLoadResult</a><span class="tsd-signature-symbol">></span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:666</li>
</ul>
</aside>
<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 return 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>) => 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>
<a href="#lifecycle" id="lifecycle" style="color: inherit; text-decoration: none;">
<h4>Lifecycle</h4>
</a>
<ul>
<li><p>The <code>lazyLoad</code> function is invoked if a transition is going to enter the state.</p>
</li>
<li><p>The function is invoked before the transition starts (using an <code>onBefore</code> transition hook).</p>
</li>
<li><p>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.</p>
</li>
<li><p>When the promise resolves successfully, the <code>lazyLoad</code> property is deleted from the state declaration.</p>
</li>
<li><p>If the promise resolves to a <a href="__uirouter_core_src_state_interface_.lazyloadresult.html">LazyLoadResult</a> which has an array of <code>states</code>, those states are registered.</p>
</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>
<a href="#lazy-loading-state-definitions-future-states" id="lazy-loading-state-definitions-future-states" style="color: inherit; text-decoration: none;">
<h3>Lazy loading state definitions (Future States)</h3>
</a>
<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's <code>name</code> property acts as a wildcard <a href="../classes/__uirouter_core_src_common_glob_.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'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="__uirouter_core_src_state_interface_.statedeclaration.html">StateDeclaration</a> objects.
It should return a <a href="__uirouter_core_src_state_interface_.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>
<a href="#additional-resources" id="additional-resources" style="color: inherit; text-decoration: none;">
<h3>Additional resources</h3>
</a>
<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>
<a href="#example-statesjs" id="example-statesjs" style="color: inherit; text-decoration: none;">
<h4>Example: states.js</h4>
</a>
<pre><code class="language-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> =></span> <span class="hljs-keyword">import</span>(<span class="hljs-string">'./lazy.states.js'</span>)
}</code></pre>
<a href="#example-lazystatesjs" id="example-lazystatesjs" style="color: inherit; text-decoration: none;">
<h4>Example: lazy.states.js</h4>
</a>
<p>This file is lazy loaded. It exports an array of states.</p>
<pre><code class="language-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>
<span class="hljs-attr">name</span>: <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>) =></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>) =></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/__uirouter_core_src_transition_transition_.transition.html">Transition</a> that is activating the future state</p>
</dd>
<dt>param</dt>
<dd><p>the <a href="__uirouter_core_src_state_interface_.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="__uirouter_core_src_state_interface_.lazyloadresult.html">LazyLoadResult</a>,
the states will be registered with the <a href="../classes/__uirouter_core_src_state_stateregistry_.stateregistry.html">StateRegistry</a>.</p>
</dd>
</dl>
</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">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>transition<span class="tsd-signature-symbol">: </span><a href="../classes/__uirouter_core_src_transition_transition_.transition.html" class="tsd-signature-type">Transition</a>, state<span class="tsd-signature-symbol">: </span><a href="__uirouter_core_src_state_interface_.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="__uirouter_core_src_state_interface_.transitionpromise.html#promise" class="tsd-signature-type">Promise</a><span class="tsd-signature-symbol"><</span><a href="__uirouter_core_src_state_interface_.lazyloadresult.html" class="tsd-signature-type">LazyLoadResult</a><span class="tsd-signature-symbol">></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/__uirouter_core_src_transition_transition_.transition.html" class="tsd-signature-type">Transition</a></h5>
</li>
<li>
<h5>state: <a href="__uirouter_core_src_state_interface_.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="__uirouter_core_src_state_interface_.transitionpromise.html#promise" class="tsd-signature-type">Promise</a><span class="tsd-signature-symbol"><</span><a href="__uirouter_core_src_state_interface_.lazyloadresult.html" class="tsd-signature-type">LazyLoadResult</a><span class="tsd-signature-symbol">></span></h4>
</li>
</ul>
</li>
</ul>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:112</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The state name (required)</p>
</div>
<p>A unique state name, e.g. <code>"home"</code>, <code>"about"</code>, <code>"contacts"</code>.
To create a parent/child state use a dot, e.g. <code>"about.sales"</code>, <code>"home.newest"</code>.</p>
<p>Note: [State] objects require unique names.
The name is used like an id.</p>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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="__uirouter_core_src_transition_interface_.transitionstatehookfn.html" class="tsd-signature-type">TransitionStateHookFn</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:498</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A Transition Hook called with the state is being entered. See: <a href="__uirouter_core_src_transition_interface_.ihookregistry.html#onenter">IHookRegistry.onEnter</a></p>
</div>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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="language-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>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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="__uirouter_core_src_transition_interface_.transitionstatehookfn.html" class="tsd-signature-type">TransitionStateHookFn</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:542</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A Transition Hook called with the state is being exited. See: <a href="__uirouter_core_src_transition_interface_.ihookregistry.html#onexit">IHookRegistry.onExit</a></p>
</div>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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="language-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>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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="__uirouter_core_src_transition_interface_.transitionstatehookfn.html" class="tsd-signature-type">TransitionStateHookFn</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:520</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A <a href="__uirouter_core_src_transition_interface_.transitionstatehookfn.html">TransitionStateHookFn</a> called with the state is being retained/kept. See: <a href="__uirouter_core_src_transition_interface_.ihookregistry.html#onretain">IHookRegistry.onRetain</a></p>
</div>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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="language-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>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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-symbol">{}</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:344</li>
</ul>
</aside>
<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="__uirouter_core_src_params_interface_.paramdeclaration.html">ParamDeclaration</a> keyed to the name of the parameter.</p>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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 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="__uirouter_core_src_params_interface_.paramdeclaration.html" class="tsd-signature-type">ParamDeclaration</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span></h5>
</li>
</ul>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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="__uirouter_core_src_state_interface_.statedeclaration.html" class="tsd-signature-type">StateDeclaration</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:146</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>The parent state</p>
</div>
<p>Normally, a state's parent is implied from the state's <a href="__uirouter_core_src_state_interface_.statedeclaration.html#name">name</a>, e.g., <code>"parentstate.childstate"</code>.</p>
<p>Alternatively, you can explicitly set the parent state using this property.
This allows shorter state names, e.g., <code><a ui-sref="childstate">Child</a></code>
instead of `<a ui-sref="parentstate.childstate">Child</a></p>
<p>When using this property, the state's name should not have any dots in it.</p>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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/__uirouter_core_src_state_interface_.html#redirecttoresult" class="tsd-signature-type">RedirectToResult</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>transition<span class="tsd-signature-symbol">: </span><a href="../classes/__uirouter_core_src_transition_transition_.transition.html" class="tsd-signature-type">Transition</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><a href="../modules/__uirouter_core_src_state_interface_.html#redirecttoresult" class="tsd-signature-type">RedirectToResult</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>transition<span class="tsd-signature-symbol">: </span><a href="../classes/__uirouter_core_src_transition_transition_.transition.html" class="tsd-signature-type">Transition</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><a href="__uirouter_core_src_state_interface_.transitionpromise.html#promise" class="tsd-signature-type">Promise</a><span class="tsd-signature-symbol"><</span><a href="../modules/__uirouter_core_src_state_interface_.html#redirecttoresult" class="tsd-signature-type">RedirectToResult</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">)</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:472</li>
</ul>
</aside>
<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'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/__uirouter_core_src_state_targetstate_.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/__uirouter_core_src_transition_transition_.transition.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/__uirouter_core_src_transition_transition_.transition.html#injector">Transition.injector</a> and get a
promise for the resolve data using <a href="__uirouter_core_src_interface_.uiinjector.html#getasync">UIInjector.getAsync</a>.</p>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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> =></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>) =></span> {
<span class="hljs-keyword">if</span> (trans.params().foo < <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>) =></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>) =></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> =></span> resolveData === <span class="hljs-string">'login'</span> ? <span class="hljs-string">'login'</span> : <span class="hljs-literal">null</span>);
}
})</code></pre>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:683</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Marks all query parameters as <a href="__uirouter_core_src_params_interface_.paramdeclaration.html#dynamic">ParamDeclaration.dynamic</a></p>
</div>
<dl class="tsd-comment-tags">
<dt>deprecated</dt>
<dd><p>use either <a href="__uirouter_core_src_state_interface_.statedeclaration.html#dynamic">dynamic</a> or <a href="__uirouter_core_src_params_interface_.paramdeclaration.html#dynamic">ParamDeclaration.dynamic</a></p>
</dd>
</dl>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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> <a href="../modules/__uirouter_core_src_state_interface_.html#resolvetypes" class="tsd-signature-type">ResolveTypes</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">{}</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:278</li>
</ul>
</aside>
<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>
<a href="#as-an-array" id="as-an-array" style="color: inherit; text-decoration: none;">
<h3>As an array</h3>
</a>
<p>Each array element should be a <a href="__uirouter_core_src_resolve_interface_.resolvableliteral.html">ResolvableLiteral</a> object.</p>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<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="language-js">var state = {
name: 'user',
url: '/user/:userId
resolve: [
{
token: 'user',
policy: { when: 'EAGER' },
deps: ['UserService', Transition],
resolveFn: (userSvc, trans) => 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="__uirouter_core_src_resolve_interface_.providerlike.html">ProviderLike</a>.</p>
<a href="#example-1" id="example-1" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<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) => http.get(<span class="hljs-string">'/'</span>), <span class="hljs-string">deps:</span> [ Http ] },
]</code></pre>
<a href="#as-an-object" id="as-an-object" style="color: inherit; text-decoration: none;">
<h3>As an object</h3>
</a>
<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">"annotated" in the AngularJS manner</a>.</p>
<a href="#angularjs-example" id="angularjs-example" style="color: inherit; text-decoration: none;">
<h4>AngularJS Example:</h4>
</a>
<pre><code class="language-js">resolve: {
<span class="hljs-comment">// If you inject `myStateDependency` into a controller, you'll get "abc"</span>
<span class="hljs-attr">myStateDependency</span>: <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>
<span class="hljs-attr">myAsyncData</span>: [<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>
<a href="#lifecycle" id="lifecycle" style="color: inherit; text-decoration: none;">
<h3>Lifecycle</h3>
</a>
<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 "retained" 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's primary data.</p>
<a href="#injecting-resolves-into-other-things" id="injecting-resolves-into-other-things" style="color: inherit; text-decoration: none;">
<h3>Injecting resolves into other things</h3>
</a>
<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>
<a href="#injecting-other-things-into-resolves" id="injecting-other-things-into-resolves" style="color: inherit; text-decoration: none;">
<h3>Injecting other things into resolves</h3>
</a>
<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>
<a href="#special-injectable-tokens" id="special-injectable-tokens" style="color: inherit; text-decoration: none;">
<h4>Special injectable tokens</h4>
</a>
<ul>
<li><code>UIRouter</code>: The <a href="../classes/__uirouter_core_src_router_.uirouter.html">UIRouter</a> instance which has references to all the UI-Router services.</li>
<li><code>Transition</code>: The current <a href="../classes/__uirouter_core_src_transition_transition_.transition.html">Transition</a> object; information and API about the current transition, such as
"to" and "from" State Parameters and transition options.</li>
<li><code>'$transition$'</code>: A string alias for the <code>Transition</code> injectable</li>
<li><code>'$state$'</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>
<a href="#example-2" id="example-2" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-js"><span class="hljs-comment">// Injecting a resolve into another resolve</span>
<span class="hljs-attr">resolve</span>: [
<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>) =></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) => _.find(allusers, trans.params().userId, <span class="hljs-attr">deps</span>: [<span class="hljs-string">'allusers'</span>, Transition] }
}</code></pre>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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="__uirouter_core_src_resolve_interface_.resolvepolicy.html" class="tsd-signature-type">ResolvePolicy</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:292</li>
</ul>
</aside>
<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="__uirouter_core_src_resolve_interface_.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: "LAZY" or "EAGER"</li>
<li><code>async</code>: (optional) if the transition waits for the resolve. Accepted values: "WAIT", "NOWAIT", <a href="__uirouter_core_src_resolve_interface_.customasyncpolicy.html">CustomAsyncPolicy</a></li>
</ul>
<p>See <a href="__uirouter_core_src_resolve_interface_.resolvepolicy.html">ResolvePolicy</a> for more details.</p>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:322</li>
</ul>
</aside>
<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's URL in order to build up the overall URL for this state.
See <a href="../classes/__uirouter_core_src_url_urlmatcher_.urlmatcher.html">UrlMatcher</a> for details on acceptable patterns.</p>
<dl class="tsd-comment-tags">
<dt>examples</dt>
<dd><pre><code class="language-js">
<span class="hljs-attr">url</span>: <span class="hljs-string">"/home"</span>
<span class="hljs-comment">// Define a parameter named 'userid'</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/users/:userid"</span>
<span class="hljs-comment">// param 'bookid' has a custom regexp</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/books/{bookid:[a-zA-Z_-]}"</span>
<span class="hljs-comment">// param 'categoryid' is of type 'int'</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/books/{categoryid:int}"</span>
<span class="hljs-comment">// two parameters for this state</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/books/{publishername:string}/{categoryid:int}"</span>
<span class="hljs-comment">// Query parameters</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/messages?before&after"</span>
<span class="hljs-comment">// Query parameters of type 'date'</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/messages?{before:date}&{after:date}"</span>
<span class="hljs-comment">// Path and query parameters</span>
<span class="hljs-attr">url</span>: <span class="hljs-string">"/messages/:mailboxid?{before:date}&{after:date}"</span></code></pre>
</dd>
</dl>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<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-symbol">{}</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in @uirouter/core/src/state/interface.ts:391</li>
</ul>
</aside>
<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><p>What is a view config</p>
</li>
<li><p>What is a ui-view</p>
</li>
<li><p>Shorthand controller/template</p>
</li>
<li><p>Incompatible with ^</p>
<p>Examples:</p>
<p>Targets three named ui-views in the parent state's template</p>
</li>
</ul>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h4>Example:</h4>
</a>
<pre><code class="language-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="language-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>
<span class="hljs-attr">views</span>: {
<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 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="__uirouter_core_src_state_interface_._viewdeclaration.html" class="tsd-signature-type">_ViewDeclaration</a></h5>
</li>
</ul>
</div>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="label ">
<span></span>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_router_.uirouter.html">UIRouter</a>
</li>
<li class="label ">
<span>Services</span>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_state_stateservice_.stateservice.html">State<wbr>Service</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_state_stateregistry_.stateregistry.html">State<wbr>Registry</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_transition_transitionservice_.transitionservice.html">Transition<wbr>Service</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_url_urlservice_.urlservice.html">Url<wbr>Service</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_url_urlconfig_.urlconfig.html">Url<wbr>Config</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_url_urlrules_.urlrules.html">Url<wbr>Rules</a>
</li>
<li class="label ">
<span>Interfaces</span>
</li>
<li class="current tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="_interface_.ng2statedeclaration.html">Ng2<wbr>State<wbr>Declaration</a>
</li>
<li class="current tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="_interface_.uionparamschanged.html">Ui<wbr>OnParams<wbr>Changed</a>
</li>
<li class="current tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="_interface_.uionexit.html">Ui<wbr>OnExit</a>
</li>
<li class="label ">
<span>Components</span>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/_directives_uiview_.uiview.html">UIView</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/_directives_uisref_.uisref.html">UISref</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/_directives_uisrefactive_.uisrefactive.html">UISref<wbr>Active</a>
</li>
<li class="label ">
<span>Other</span>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_transition_transition_.transition.html">Transition</a>
</li>
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
<a href="../classes/__uirouter_core_src_common_trace_.trace.html">Trace</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="__uirouter_core_src_state_interface_.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="__uirouter_core_src_state_interface_.lazyloadresult.html" class="tsd-kind-icon">Lazy<wbr>Load<wbr>Result</a>
</li>
</ul>
<ul class="current">
<li class="current tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html" class="tsd-kind-icon">State<wbr>Declaration</a>
<ul>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#abstract" class="tsd-kind-icon">abstract</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#data" class="tsd-kind-icon">data</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#dynamic" class="tsd-kind-icon">dynamic</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#lazyload" class="tsd-kind-icon">lazy<wbr>Load</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#name" class="tsd-kind-icon">name</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#onenter" class="tsd-kind-icon">on<wbr>Enter</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#onexit" class="tsd-kind-icon">on<wbr>Exit</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#onretain" class="tsd-kind-icon">on<wbr>Retain</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#params" class="tsd-kind-icon">params</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#parent" class="tsd-kind-icon">parent</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#redirectto" class="tsd-kind-icon">redirect<wbr>To</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#reloadonsearch" class="tsd-kind-icon">reload<wbr>OnSearch</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#resolve" class="tsd-kind-icon">resolve</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
<a href="__uirouter_core_src_state_interface_.statedeclaration.html#resolvepolicy" class="tsd-kind-icon">resolve<wbr>Policy</a>
</li>