@angular-wave/angular.ts 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +1 -1
- package/README.md +3 -3
- package/TODO.md +14 -0
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/index.html +2 -1
- package/package.json +1 -1
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +15 -6
- package/src/animations/animate-js.js +1 -1
- package/src/animations/animate-queue.js +1 -1
- package/src/animations/shared.js +0 -14
- package/src/core/compile.js +6 -3
- package/src/core/q.js +9 -9
- package/src/core/sanitize-uri.js +1 -1
- package/src/core/sce.js +1 -1
- package/src/directive/if.js +0 -79
- package/src/directive/if.md +80 -0
- package/src/directive/include.js +0 -82
- package/src/directive/include.md +86 -0
- package/src/directive/repeat.js +0 -1
- package/src/loader.js +0 -1
- package/src/public.js +0 -2
- package/src/router/common/trace.js +1 -1
- package/src/router/directives/stateDirectives.js +16 -14
- package/src/router/directives/viewDirective.js +2 -2
- package/src/router/hooks/resolve.js +3 -4
- package/src/router/hooks/views.js +3 -2
- package/src/router/state/stateService.js +1 -2
- package/src/router/transition/interface.js +14 -14
- package/src/router/transition/rejectFactory.js +29 -20
- package/src/router/transition/transitionHook.js +5 -5
- package/src/router/url/urlMatcher.js +1 -2
- package/src/router/url/urlRule.js +1 -1
- package/src/router/url/urlRules.js +1 -1
- package/src/shared/common.js +0 -1
- package/test/module-test.html +44 -12
- package/test/router/services.spec.js +71 -0
- package/test/router/state-directives.spec.js +1208 -0
- package/types/angular.d.ts +132 -124
- package/types/index.d.ts +2350 -2187
- package/types/jqlite.d.ts +463 -418
- package/types/router/core/common/common.d.ts +70 -24
- package/types/router/core/common/coreservices.d.ts +30 -32
- package/types/router/core/common/glob.d.ts +9 -9
- package/types/router/core/common/hof.d.ts +12 -4
- package/types/router/core/common/index.d.ts +8 -8
- package/types/router/core/common/predicates.d.ts +1 -1
- package/types/router/core/common/queue.d.ts +13 -13
- package/types/router/core/common/safeConsole.d.ts +3 -3
- package/types/router/core/common/strings.d.ts +4 -2
- package/types/router/core/common/trace.d.ts +94 -82
- package/types/router/core/globals.d.ts +37 -37
- package/types/router/core/hooks/coreResolvables.d.ts +5 -3
- package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
- package/types/router/core/hooks/invalidTransition.d.ts +4 -2
- package/types/router/core/hooks/lazyLoad.d.ts +10 -5
- package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
- package/types/router/core/hooks/redirectTo.d.ts +4 -2
- package/types/router/core/hooks/resolve.d.ts +10 -4
- package/types/router/core/hooks/updateGlobals.d.ts +4 -2
- package/types/router/core/hooks/url.d.ts +4 -2
- package/types/router/core/hooks/views.d.ts +7 -3
- package/types/router/core/index.d.ts +11 -12
- package/types/router/core/interface.d.ts +83 -81
- package/types/router/core/params/index.d.ts +5 -5
- package/types/router/core/params/interface.d.ts +439 -439
- package/types/router/core/params/param.d.ts +72 -60
- package/types/router/core/params/paramType.d.ts +40 -40
- package/types/router/core/params/paramTypes.d.ts +169 -165
- package/types/router/core/params/stateParams.d.ts +13 -13
- package/types/router/core/path/index.d.ts +2 -2
- package/types/router/core/path/pathNode.d.ts +49 -49
- package/types/router/core/path/pathUtils.d.ts +100 -74
- package/types/router/core/resolve/index.d.ts +3 -3
- package/types/router/core/resolve/interface.d.ts +137 -137
- package/types/router/core/resolve/resolvable.d.ts +60 -54
- package/types/router/core/resolve/resolveContext.d.ts +84 -79
- package/types/router/core/router.d.ts +95 -86
- package/types/router/core/state/index.d.ts +8 -8
- package/types/router/core/state/interface.d.ts +667 -643
- package/types/router/core/state/stateBuilder.d.ts +41 -38
- package/types/router/core/state/stateMatcher.d.ts +11 -9
- package/types/router/core/state/stateObject.d.ts +154 -139
- package/types/router/core/state/stateQueueManager.d.ts +26 -21
- package/types/router/core/state/stateRegistry.d.ts +124 -121
- package/types/router/core/state/stateService.d.ts +380 -343
- package/types/router/core/state/targetState.d.ts +74 -69
- package/types/router/core/transition/hookBuilder.d.ts +34 -30
- package/types/router/core/transition/hookRegistry.d.ts +96 -74
- package/types/router/core/transition/index.d.ts +8 -8
- package/types/router/core/transition/interface.d.ts +652 -609
- package/types/router/core/transition/rejectFactory.d.ts +97 -97
- package/types/router/core/transition/transition.d.ts +565 -517
- package/types/router/core/transition/transitionEventType.d.ts +20 -11
- package/types/router/core/transition/transitionHook.d.ts +90 -82
- package/types/router/core/transition/transitionService.d.ts +228 -161
- package/types/router/core/url/index.d.ts +8 -8
- package/types/router/core/url/interface.d.ts +100 -87
- package/types/router/core/url/urlConfig.d.ts +130 -126
- package/types/router/core/url/urlMatcher.d.ts +132 -127
- package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
- package/types/router/core/url/urlRouter.d.ts +91 -75
- package/types/router/core/url/urlRule.d.ts +123 -100
- package/types/router/core/url/urlRules.d.ts +240 -232
- package/types/router/core/url/urlService.d.ts +201 -201
- package/types/router/core/view/index.d.ts +2 -2
- package/types/router/core/view/interface.d.ts +26 -26
- package/types/router/core/view/view.d.ts +152 -143
- package/types/router/directives/viewDirective.d.ts +12 -11
- package/types/router/index.d.ts +11 -12
- package/types/router/interface.d.ts +361 -351
- package/types/router/legacy/resolveService.d.ts +44 -40
- package/types/router/legacy/stateEvents.d.ts +1 -1
- package/types/router/locationServices.d.ts +45 -37
- package/types/router/services.d.ts +9 -9
- package/types/router/stateFilters.d.ts +3 -3
- package/types/router/stateProvider.d.ts +240 -235
- package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
- package/types/router/statebuilders/views.d.ts +35 -22
- package/types/router/templateFactory.d.ts +99 -79
- package/types/router/viewScroll.d.ts +7 -7
- package/src/directive/a.js +0 -37
- package/test/directive/a.spec.js +0 -192
- package/types/router/angular.d.ts +0 -1
- package/types/router/core/vanilla.d.ts +0 -1
- package/types/router/directives/stateDirectives.d.ts +0 -3
- package/types/router/injectables.d.ts +0 -1
package/src/public.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $CompileProvider } from "./core/compile";
|
|
2
|
-
import { htmlAnchorDirective } from "./directive/a";
|
|
3
2
|
import {
|
|
4
3
|
inputDirective,
|
|
5
4
|
ngValueDirective,
|
|
@@ -117,7 +116,6 @@ export function publishExternalAPI() {
|
|
|
117
116
|
$provide
|
|
118
117
|
.provider("$compile", $CompileProvider)
|
|
119
118
|
.directive({
|
|
120
|
-
a: htmlAnchorDirective,
|
|
121
119
|
input: inputDirective,
|
|
122
120
|
textarea: inputDirective,
|
|
123
121
|
form: formDirective,
|
|
@@ -142,7 +142,7 @@ export class Trace {
|
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
/** @internal called by ui-router code */
|
|
145
|
-
traceHookResult(hookResult, trans
|
|
145
|
+
traceHookResult(hookResult, trans) {
|
|
146
146
|
if (!this.enabled(Category.HOOK)) return;
|
|
147
147
|
console.log(
|
|
148
148
|
`${transLbl(trans)}: <- Hook returned: ${maxLength(200, stringify(hookResult))}`,
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import {
|
|
9
9
|
forEach,
|
|
10
10
|
tail,
|
|
11
|
-
noop,
|
|
12
11
|
unnestR,
|
|
13
12
|
identity,
|
|
14
13
|
uniqR,
|
|
@@ -63,16 +62,15 @@ function clickHook(el, $state, $timeout, type, getDef) {
|
|
|
63
62
|
return function (e) {
|
|
64
63
|
const button = e.which || e.button,
|
|
65
64
|
target = getDef();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
) {
|
|
65
|
+
|
|
66
|
+
let res =
|
|
67
|
+
button > 1 ||
|
|
68
|
+
e.ctrlKey ||
|
|
69
|
+
e.metaKey ||
|
|
70
|
+
e.shiftKey ||
|
|
71
|
+
e.altKey ||
|
|
72
|
+
el.attr("target");
|
|
73
|
+
if (!res) {
|
|
76
74
|
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
|
|
77
75
|
const transition = $timeout(function () {
|
|
78
76
|
if (!el.attr("disabled")) {
|
|
@@ -85,6 +83,10 @@ function clickHook(el, $state, $timeout, type, getDef) {
|
|
|
85
83
|
e.preventDefault = function () {
|
|
86
84
|
if (ignorePreventDefaultCount-- <= 0) $timeout.cancel(transition);
|
|
87
85
|
};
|
|
86
|
+
} else {
|
|
87
|
+
// ignored
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
e.stopImmediatePropagation();
|
|
88
90
|
}
|
|
89
91
|
};
|
|
90
92
|
}
|
|
@@ -257,7 +259,7 @@ export let uiSrefDirective = [
|
|
|
257
259
|
return {
|
|
258
260
|
restrict: "A",
|
|
259
261
|
require: ["?^uiSrefActive", "?^uiSrefActiveEq"],
|
|
260
|
-
link:
|
|
262
|
+
link: (scope, element, attrs, uiSrefActive) => {
|
|
261
263
|
const type = getTypeInfo(element);
|
|
262
264
|
const active = uiSrefActive[1] || uiSrefActive[0];
|
|
263
265
|
let unlinkInfoFn = null;
|
|
@@ -400,7 +402,7 @@ export let uiStateDirective = [
|
|
|
400
402
|
const getDef = () => processedDef($state, element, rawDef);
|
|
401
403
|
const inputAttrs = ["uiState", "uiStateParams", "uiStateOpts"];
|
|
402
404
|
const watchDeregFns = inputAttrs.reduce(
|
|
403
|
-
(acc, attr) => ((acc[attr] =
|
|
405
|
+
(acc, attr) => ((acc[attr] = () => {}), acc),
|
|
404
406
|
{},
|
|
405
407
|
);
|
|
406
408
|
function update() {
|
|
@@ -579,7 +581,7 @@ export let uiSrefActiveDirective = [
|
|
|
579
581
|
return deregister;
|
|
580
582
|
};
|
|
581
583
|
function updateAfterTransition(trans) {
|
|
582
|
-
trans.promise.then(update,
|
|
584
|
+
trans.promise.then(update, () => {});
|
|
583
585
|
}
|
|
584
586
|
$scope.$on("$destroy", setupEventListeners());
|
|
585
587
|
if ($router.globals.transition) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { filter, tail, unnestR } from "../../shared/common";
|
|
2
2
|
import { isDefined, isFunction, isString } from "../../shared/utils";
|
|
3
3
|
import { kebobString } from "../../shared/strings";
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import { parse } from "../../shared/hof";
|
|
6
6
|
import { ResolveContext } from "../resolve/resolveContext";
|
|
7
7
|
import { trace } from "../common/trace";
|
|
@@ -338,7 +338,7 @@ export function $ViewDirectiveFill(
|
|
|
338
338
|
);
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
|
-
const cfg = data.$cfg || { viewDecl: {}, getTemplate:
|
|
341
|
+
const cfg = data.$cfg || { viewDecl: {}, getTemplate: () => {} };
|
|
342
342
|
const resolveCtx = cfg.path && new ResolveContext(cfg.path);
|
|
343
343
|
$element.html(cfg.getTemplate($element, resolveCtx) || initial);
|
|
344
344
|
trace.traceUIViewFill(data.$uiView, $element.html());
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { noop } from "../../shared/common";
|
|
2
1
|
import { ResolveContext } from "../resolve/resolveContext";
|
|
3
2
|
import { val } from "../../shared/hof";
|
|
4
3
|
export const RESOLVE_HOOK_PRIORITY = 1000;
|
|
@@ -14,7 +13,7 @@ export const RESOLVE_HOOK_PRIORITY = 1000;
|
|
|
14
13
|
const eagerResolvePath = (trans) =>
|
|
15
14
|
new ResolveContext(trans.treeChanges().to)
|
|
16
15
|
.resolvePath("EAGER", trans)
|
|
17
|
-
.then(
|
|
16
|
+
.then(() => {});
|
|
18
17
|
export const registerEagerResolvePath = (transitionService) =>
|
|
19
18
|
transitionService.onStart({}, eagerResolvePath, {
|
|
20
19
|
priority: RESOLVE_HOOK_PRIORITY,
|
|
@@ -32,7 +31,7 @@ const lazyResolveState = (trans, state) =>
|
|
|
32
31
|
new ResolveContext(trans.treeChanges().to)
|
|
33
32
|
.subContext(state.$$state())
|
|
34
33
|
.resolvePath("LAZY", trans)
|
|
35
|
-
.then(
|
|
34
|
+
.then(() => {});
|
|
36
35
|
export const registerLazyResolveState = (transitionService) =>
|
|
37
36
|
transitionService.onEnter({ entering: val(true) }, lazyResolveState, {
|
|
38
37
|
priority: RESOLVE_HOOK_PRIORITY,
|
|
@@ -50,7 +49,7 @@ export const registerLazyResolveState = (transitionService) =>
|
|
|
50
49
|
const resolveRemaining = (trans) =>
|
|
51
50
|
new ResolveContext(trans.treeChanges().to)
|
|
52
51
|
.resolvePath("LAZY", trans)
|
|
53
|
-
.then(
|
|
52
|
+
.then(() => {});
|
|
54
53
|
export const registerResolveRemaining = (transitionService) =>
|
|
55
54
|
transitionService.onFinish({}, resolveRemaining, {
|
|
56
55
|
priority: RESOLVE_HOOK_PRIORITY,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { noop } from "../../shared/common";
|
|
2
1
|
import { services } from "../common/coreservices";
|
|
3
2
|
/**
|
|
4
3
|
* A [[TransitionHookFn]] which waits for the views to load
|
|
@@ -12,7 +11,9 @@ const loadEnteringViews = (transition) => {
|
|
|
12
11
|
const $q = services.$q;
|
|
13
12
|
const enteringViews = transition.views("entering");
|
|
14
13
|
if (!enteringViews.length) return;
|
|
15
|
-
return $q
|
|
14
|
+
return $q
|
|
15
|
+
.all(enteringViews.map((view) => $q.when(view.load())))
|
|
16
|
+
.then(() => {});
|
|
16
17
|
};
|
|
17
18
|
export const registerLoadEnteringViews = (transitionService) =>
|
|
18
19
|
transitionService.onFinish({}, loadEnteringViews);
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
createProxyFunctions,
|
|
3
3
|
defaults,
|
|
4
4
|
inArray,
|
|
5
|
-
noop,
|
|
6
5
|
removeFrom,
|
|
7
6
|
silenceUncaughtInPromise,
|
|
8
7
|
silentRejection,
|
|
@@ -86,7 +85,7 @@ export class StateService {
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
dispose() {
|
|
89
|
-
this.defaultErrorHandler(
|
|
88
|
+
this.defaultErrorHandler(() => {});
|
|
90
89
|
this.invalidCallbacks = [];
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/** An object for Transition Hook Phases */
|
|
2
|
+
export const TransitionHookPhase = {
|
|
3
|
+
CREATE: 0,
|
|
4
|
+
BEFORE: 1,
|
|
5
|
+
RUN: 2,
|
|
6
|
+
SUCCESS: 3,
|
|
7
|
+
ERROR: 4,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** An object for Transition Hook Scopes */
|
|
11
|
+
export const TransitionHookScope = {
|
|
12
|
+
TRANSITION: 0,
|
|
13
|
+
STATE: 1,
|
|
14
|
+
};
|
|
@@ -1,47 +1,56 @@
|
|
|
1
1
|
import { silentRejection } from "../../shared/common";
|
|
2
2
|
import { stringify } from "../../shared/strings";
|
|
3
3
|
import { is } from "../../shared/hof";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An object for Transition Rejection reasons.
|
|
7
|
+
* @enum {number}
|
|
8
|
+
*/
|
|
9
|
+
export const RejectType = {
|
|
7
10
|
/**
|
|
8
11
|
* A new transition superseded this one.
|
|
9
12
|
*
|
|
10
13
|
* While this transition was running, a new transition started.
|
|
11
|
-
* This transition is cancelled because it was superseded by new transition.
|
|
14
|
+
* This transition is cancelled because it was superseded by a new transition.
|
|
15
|
+
* @type {number}
|
|
12
16
|
*/
|
|
13
|
-
|
|
17
|
+
SUPERSEDED: 2,
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
|
-
* The transition was aborted
|
|
20
|
+
* The transition was aborted.
|
|
16
21
|
*
|
|
17
|
-
* The transition was aborted by a hook which returned `false
|
|
22
|
+
* The transition was aborted by a hook which returned `false`.
|
|
23
|
+
* @type {number}
|
|
18
24
|
*/
|
|
19
|
-
|
|
25
|
+
ABORTED: 3,
|
|
26
|
+
|
|
20
27
|
/**
|
|
21
|
-
* The transition was invalid
|
|
28
|
+
* The transition was invalid.
|
|
22
29
|
*
|
|
23
|
-
* The transition was never started because it was invalid
|
|
30
|
+
* The transition was never started because it was invalid.
|
|
31
|
+
* @type {number}
|
|
24
32
|
*/
|
|
25
|
-
|
|
33
|
+
INVALID: 4,
|
|
34
|
+
|
|
26
35
|
/**
|
|
27
|
-
* The transition was ignored
|
|
36
|
+
* The transition was ignored.
|
|
28
37
|
*
|
|
29
38
|
* The transition was ignored because it would have no effect.
|
|
30
|
-
*
|
|
31
39
|
* Either:
|
|
32
|
-
*
|
|
33
|
-
* - The transition is targeting the current state and parameter values
|
|
40
|
+
* - The transition is targeting the current state and parameter values.
|
|
34
41
|
* - The transition is targeting the same state and parameter values as the currently running transition.
|
|
42
|
+
* @type {number}
|
|
35
43
|
*/
|
|
36
|
-
|
|
44
|
+
IGNORED: 5,
|
|
45
|
+
|
|
37
46
|
/**
|
|
38
47
|
* The transition errored.
|
|
39
48
|
*
|
|
40
|
-
* This generally means a hook threw an error or returned a rejected promise
|
|
49
|
+
* This generally means a hook threw an error or returned a rejected promise.
|
|
50
|
+
* @type {number}
|
|
41
51
|
*/
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
export { RejectType };
|
|
52
|
+
ERROR: 6,
|
|
53
|
+
};
|
|
45
54
|
|
|
46
55
|
let id = 0;
|
|
47
56
|
export class Rejection {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransitionHookPhase } from "./interface";
|
|
2
|
-
import { defaults,
|
|
2
|
+
import { defaults, silentRejection } from "../../shared/common";
|
|
3
3
|
import { fnToString, maxLength } from "../../shared/strings";
|
|
4
4
|
import { isPromise } from "../../shared/predicates";
|
|
5
5
|
import { is, parse } from "../../shared/hof";
|
|
@@ -8,7 +8,7 @@ import { services } from "../common/coreservices";
|
|
|
8
8
|
import { Rejection } from "./rejectFactory";
|
|
9
9
|
import { TargetState } from "../state/targetState";
|
|
10
10
|
const defaultOptions = {
|
|
11
|
-
current:
|
|
11
|
+
current: () => {},
|
|
12
12
|
transition: null,
|
|
13
13
|
traceData: {},
|
|
14
14
|
bind: null,
|
|
@@ -127,7 +127,7 @@ export class TransitionHook {
|
|
|
127
127
|
// Wait for the promise, then reprocess with the resulting value
|
|
128
128
|
return result.then((val) => this.handleHookResult(val));
|
|
129
129
|
}
|
|
130
|
-
trace.traceHookResult(result, this.transition
|
|
130
|
+
trace.traceHookResult(result, this.transition);
|
|
131
131
|
// Hook returned false
|
|
132
132
|
if (result === false) {
|
|
133
133
|
// Abort this Transition
|
|
@@ -193,7 +193,7 @@ TransitionHook.LOG_REJECTED_RESULT = (hook) => (result) => {
|
|
|
193
193
|
* Each HookType chooses a GetErrorHandler (See: [[TransitionService._defineCoreEvents]])
|
|
194
194
|
*/
|
|
195
195
|
TransitionHook.LOG_ERROR = (hook) => (error) => hook.logError(error);
|
|
196
|
-
TransitionHook.REJECT_ERROR = (
|
|
197
|
-
TransitionHook.THROW_ERROR = (
|
|
196
|
+
TransitionHook.REJECT_ERROR = () => (error) => silentRejection(error);
|
|
197
|
+
TransitionHook.THROW_ERROR = () => (error) => {
|
|
198
198
|
throw error;
|
|
199
199
|
};
|
|
@@ -347,11 +347,10 @@ export class UrlMatcher {
|
|
|
347
347
|
* @param path The URL path to match, e.g. `$location.path()`.
|
|
348
348
|
* @param search URL search parameters, e.g. `$location.search()`.
|
|
349
349
|
* @param hash URL hash e.g. `$location.hash()`.
|
|
350
|
-
* @param options
|
|
351
350
|
*
|
|
352
351
|
* @returns The captured parameter values.
|
|
353
352
|
*/
|
|
354
|
-
exec(path, search = {}, hash
|
|
353
|
+
exec(path, search = {}, hash) {
|
|
355
354
|
const match = memoizeTo(this._cache, "pattern", () => {
|
|
356
355
|
return new RegExp(
|
|
357
356
|
[
|
|
@@ -199,7 +199,7 @@ export class BaseUrlRule {
|
|
|
199
199
|
constructor(match, handler) {
|
|
200
200
|
this.match = match;
|
|
201
201
|
this.type = "RAW";
|
|
202
|
-
this.matchPriority = (
|
|
202
|
+
this.matchPriority = () => 0 - this.$id;
|
|
203
203
|
this.handler = handler || identity;
|
|
204
204
|
}
|
|
205
205
|
}
|
package/src/shared/common.js
CHANGED
package/test/module-test.html
CHANGED
|
@@ -6,21 +6,53 @@
|
|
|
6
6
|
<script>
|
|
7
7
|
document.addEventListener("DOMContentLoaded", () => {
|
|
8
8
|
var myApp = window.angular.module("test", ["ui.router"]);
|
|
9
|
-
myApp
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
myApp
|
|
10
|
+
.config(function ($stateProvider) {
|
|
11
|
+
$stateProvider
|
|
12
|
+
.state({ name: "top", url: "" })
|
|
13
|
+
.state({ name: "other", url: "/other/:id", template: "other" })
|
|
14
|
+
.state({
|
|
15
|
+
name: "other.detail",
|
|
16
|
+
url: "/detail",
|
|
17
|
+
template: "detail",
|
|
18
|
+
})
|
|
19
|
+
.state({
|
|
20
|
+
name: "contacts",
|
|
21
|
+
url: "/contacts",
|
|
22
|
+
template:
|
|
23
|
+
'<a ui-sref=".item({ id: 5 })" class="item">Person</a> <ui-view></ui-view>',
|
|
24
|
+
})
|
|
25
|
+
.state({
|
|
26
|
+
name: "contacts.item",
|
|
27
|
+
url: "/{id:int}",
|
|
28
|
+
template:
|
|
29
|
+
'<a ui-sref=".detail" class="item-detail">Detail</a> | <a ui-sref="^" class="item-parent">Parent</a> | <ui-view></ui-view>',
|
|
30
|
+
})
|
|
31
|
+
.state({
|
|
32
|
+
name: "contacts.item.detail",
|
|
33
|
+
url: "/{id}",
|
|
34
|
+
template:
|
|
35
|
+
'<div class="title">Detail</div> | <a ui-sref="^" class="item-parent2">Item</a>',
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.controller(
|
|
39
|
+
"TestController",
|
|
40
|
+
class {
|
|
41
|
+
constructor($q) {
|
|
42
|
+
const defer = $q.defer();
|
|
43
|
+
this.contact = defer.promise;
|
|
44
|
+
this.test = 1;
|
|
45
|
+
defer.resolve({ id: 6 });
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
);
|
|
18
49
|
});
|
|
19
50
|
</script>
|
|
20
51
|
</head>
|
|
21
52
|
<body ng-app="test">
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
53
|
+
<div ng-controller="TestController as $ctrl">
|
|
54
|
+
{{$ctrl.test}}
|
|
55
|
+
<a ui-sref="contacts.item.detail({ id: contact.id })">Details</a>
|
|
56
|
+
</div>
|
|
25
57
|
</body>
|
|
26
58
|
</html>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Angular } from "../../src/loader";
|
|
2
|
+
import { publishExternalAPI } from "../../src/public";
|
|
3
|
+
|
|
4
|
+
describe("router services", () => {
|
|
5
|
+
let providers;
|
|
6
|
+
let $routerProvider;
|
|
7
|
+
let $injector;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
window.angular = new Angular();
|
|
11
|
+
publishExternalAPI();
|
|
12
|
+
let module = window.angular.module("defaultModule", ["ui.router"]);
|
|
13
|
+
module.config(
|
|
14
|
+
(
|
|
15
|
+
_$routerProvider_,
|
|
16
|
+
$urlMatcherFactoryProvider,
|
|
17
|
+
$stateRegistryProvider,
|
|
18
|
+
$routerGlobalsProvider,
|
|
19
|
+
$transitionsProvider,
|
|
20
|
+
$stateProvider,
|
|
21
|
+
) => {
|
|
22
|
+
debugger;
|
|
23
|
+
$routerProvider = _$routerProvider_;
|
|
24
|
+
expect($routerProvider["router"]).toBe($routerProvider);
|
|
25
|
+
providers = {
|
|
26
|
+
$routerProvider,
|
|
27
|
+
$urlMatcherFactoryProvider,
|
|
28
|
+
$stateRegistryProvider,
|
|
29
|
+
$routerGlobalsProvider,
|
|
30
|
+
$transitionsProvider,
|
|
31
|
+
$stateProvider,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
$injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
37
|
+
"defaultModule",
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("Should expose ui-router providers from the UIRouter instance", () => {
|
|
42
|
+
expect(providers.$urlMatcherFactoryProvider).toBe(
|
|
43
|
+
$routerProvider.urlMatcherFactory,
|
|
44
|
+
);
|
|
45
|
+
expect(providers.$urlRouterProvider).toBe(
|
|
46
|
+
$routerProvider.urlRouterProvider,
|
|
47
|
+
);
|
|
48
|
+
expect(providers.$stateRegistryProvider).toBe(
|
|
49
|
+
$routerProvider.stateRegistry,
|
|
50
|
+
);
|
|
51
|
+
expect(providers.$routerGlobalsProvider).toBe($routerProvider.globals);
|
|
52
|
+
expect(providers.$transitionsProvider).toBe(
|
|
53
|
+
$routerProvider.transitionService,
|
|
54
|
+
);
|
|
55
|
+
expect(providers.$stateProvider).toBe($routerProvider.stateProvider);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("Should expose ui-router services from the UIRouter instance", () => {
|
|
59
|
+
let $router = $injector.get("$router");
|
|
60
|
+
expect($router).toBe($routerProvider);
|
|
61
|
+
expect($injector.get("$urlMatcherFactory")).toBe($router.urlMatcherFactory);
|
|
62
|
+
expect($injector.get("$urlService")).toBe($router.urlService);
|
|
63
|
+
expect($injector.get("$stateRegistry")).toBe($router.stateRegistry);
|
|
64
|
+
expect($injector.get("$routerGlobals")).toBe($router.globals);
|
|
65
|
+
expect($injector.get("$transitions")).toBe($router.transitionService);
|
|
66
|
+
expect($injector.get("$state")).toBe($router.stateService);
|
|
67
|
+
expect($injector.get("$stateParams")).toBe($router.globals.params);
|
|
68
|
+
expect($injector.get("$view")).toBe($router.viewService);
|
|
69
|
+
expect($injector.get("$trace")).toBeDefined();
|
|
70
|
+
});
|
|
71
|
+
});
|