@angular-wave/angular.ts 0.0.21 → 0.0.23

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.
Files changed (134) hide show
  1. package/Makefile +1 -1
  2. package/TODO.md +14 -0
  3. package/dist/angular-ts.esm.js +1 -1
  4. package/dist/angular-ts.umd.js +1 -1
  5. package/index.html +8 -2
  6. package/package.json +1 -1
  7. package/src/animations/animate-css-driver.js +2 -2
  8. package/src/animations/animate-css.js +15 -6
  9. package/src/animations/animate-js.js +1 -1
  10. package/src/animations/animate-queue.js +1 -1
  11. package/src/animations/shared.js +0 -14
  12. package/src/core/compile.js +6 -3
  13. package/src/directive/if.js +0 -79
  14. package/src/directive/if.md +80 -0
  15. package/src/directive/include.js +0 -82
  16. package/src/directive/include.md +86 -0
  17. package/src/directive/repeat.js +0 -1
  18. package/src/filters/order-by.js +8 -8
  19. package/src/loader.js +0 -1
  20. package/src/router/common/trace.js +1 -1
  21. package/src/router/directives/stateDirectives.js +16 -14
  22. package/src/router/directives/viewDirective.js +5 -13
  23. package/src/router/hooks/resolve.js +3 -4
  24. package/src/router/hooks/views.js +3 -2
  25. package/src/router/state/stateService.js +1 -2
  26. package/src/router/stateProvider.js +8 -0
  27. package/src/router/templateFactory.js +13 -7
  28. package/src/router/transition/interface.js +14 -14
  29. package/src/router/transition/rejectFactory.js +29 -20
  30. package/src/router/transition/transition.js +5 -1
  31. package/src/router/transition/transitionHook.js +5 -5
  32. package/src/router/url/urlMatcher.js +1 -2
  33. package/src/router/url/urlRule.js +10 -2
  34. package/src/router/url/urlRules.js +1 -1
  35. package/src/services/browser.js +3 -18
  36. package/src/shared/common.js +0 -1
  37. package/test/module-test.html +44 -12
  38. package/test/router/ng-state-builder.spec.js +81 -0
  39. package/test/router/services.spec.js +70 -0
  40. package/test/router/state-directives.spec.js +1182 -0
  41. package/test/router/template-factory.spec.js +146 -0
  42. package/test/router/url-matcher-factory.spec.js +1313 -0
  43. package/test/router/view-directive.spec.js +2013 -0
  44. package/test/router/view-hook.spec.js +217 -0
  45. package/test/router/view-scroll.spec.js +77 -0
  46. package/test/router/view.spec.js +117 -0
  47. package/types/angular.d.ts +132 -124
  48. package/types/index.d.ts +2350 -2187
  49. package/types/jqlite.d.ts +463 -418
  50. package/types/router/core/common/common.d.ts +70 -24
  51. package/types/router/core/common/coreservices.d.ts +30 -32
  52. package/types/router/core/common/glob.d.ts +9 -9
  53. package/types/router/core/common/hof.d.ts +12 -4
  54. package/types/router/core/common/index.d.ts +8 -8
  55. package/types/router/core/common/predicates.d.ts +1 -1
  56. package/types/router/core/common/queue.d.ts +13 -13
  57. package/types/router/core/common/safeConsole.d.ts +3 -3
  58. package/types/router/core/common/strings.d.ts +4 -2
  59. package/types/router/core/common/trace.d.ts +94 -82
  60. package/types/router/core/globals.d.ts +37 -37
  61. package/types/router/core/hooks/coreResolvables.d.ts +5 -3
  62. package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
  63. package/types/router/core/hooks/invalidTransition.d.ts +4 -2
  64. package/types/router/core/hooks/lazyLoad.d.ts +10 -5
  65. package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
  66. package/types/router/core/hooks/redirectTo.d.ts +4 -2
  67. package/types/router/core/hooks/resolve.d.ts +10 -4
  68. package/types/router/core/hooks/updateGlobals.d.ts +4 -2
  69. package/types/router/core/hooks/url.d.ts +4 -2
  70. package/types/router/core/hooks/views.d.ts +7 -3
  71. package/types/router/core/index.d.ts +11 -12
  72. package/types/router/core/interface.d.ts +83 -81
  73. package/types/router/core/params/index.d.ts +5 -5
  74. package/types/router/core/params/interface.d.ts +439 -439
  75. package/types/router/core/params/param.d.ts +72 -60
  76. package/types/router/core/params/paramType.d.ts +40 -40
  77. package/types/router/core/params/paramTypes.d.ts +169 -165
  78. package/types/router/core/params/stateParams.d.ts +13 -13
  79. package/types/router/core/path/index.d.ts +2 -2
  80. package/types/router/core/path/pathNode.d.ts +49 -49
  81. package/types/router/core/path/pathUtils.d.ts +100 -74
  82. package/types/router/core/resolve/index.d.ts +3 -3
  83. package/types/router/core/resolve/interface.d.ts +137 -137
  84. package/types/router/core/resolve/resolvable.d.ts +60 -54
  85. package/types/router/core/resolve/resolveContext.d.ts +84 -79
  86. package/types/router/core/router.d.ts +95 -86
  87. package/types/router/core/state/index.d.ts +8 -8
  88. package/types/router/core/state/interface.d.ts +667 -643
  89. package/types/router/core/state/stateBuilder.d.ts +41 -38
  90. package/types/router/core/state/stateMatcher.d.ts +11 -9
  91. package/types/router/core/state/stateObject.d.ts +154 -139
  92. package/types/router/core/state/stateQueueManager.d.ts +26 -21
  93. package/types/router/core/state/stateRegistry.d.ts +124 -121
  94. package/types/router/core/state/stateService.d.ts +380 -343
  95. package/types/router/core/state/targetState.d.ts +74 -69
  96. package/types/router/core/transition/hookBuilder.d.ts +34 -30
  97. package/types/router/core/transition/hookRegistry.d.ts +96 -74
  98. package/types/router/core/transition/index.d.ts +8 -8
  99. package/types/router/core/transition/interface.d.ts +652 -609
  100. package/types/router/core/transition/rejectFactory.d.ts +97 -97
  101. package/types/router/core/transition/transition.d.ts +565 -517
  102. package/types/router/core/transition/transitionEventType.d.ts +20 -11
  103. package/types/router/core/transition/transitionHook.d.ts +90 -82
  104. package/types/router/core/transition/transitionService.d.ts +228 -161
  105. package/types/router/core/url/index.d.ts +8 -8
  106. package/types/router/core/url/interface.d.ts +100 -87
  107. package/types/router/core/url/urlConfig.d.ts +130 -126
  108. package/types/router/core/url/urlMatcher.d.ts +132 -127
  109. package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
  110. package/types/router/core/url/urlRouter.d.ts +91 -75
  111. package/types/router/core/url/urlRule.d.ts +123 -100
  112. package/types/router/core/url/urlRules.d.ts +240 -232
  113. package/types/router/core/url/urlService.d.ts +201 -201
  114. package/types/router/core/view/index.d.ts +2 -2
  115. package/types/router/core/view/interface.d.ts +26 -26
  116. package/types/router/core/view/view.d.ts +152 -143
  117. package/types/router/directives/viewDirective.d.ts +12 -11
  118. package/types/router/index.d.ts +11 -12
  119. package/types/router/interface.d.ts +361 -351
  120. package/types/router/legacy/resolveService.d.ts +44 -40
  121. package/types/router/legacy/stateEvents.d.ts +1 -1
  122. package/types/router/locationServices.d.ts +45 -37
  123. package/types/router/services.d.ts +9 -9
  124. package/types/router/stateFilters.d.ts +3 -3
  125. package/types/router/stateProvider.d.ts +240 -235
  126. package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
  127. package/types/router/statebuilders/views.d.ts +35 -22
  128. package/types/router/templateFactory.d.ts +99 -79
  129. package/types/router/viewScroll.d.ts +7 -7
  130. package/src/directive/a.js +0 -37
  131. package/types/router/angular.d.ts +0 -1
  132. package/types/router/core/vanilla.d.ts +0 -1
  133. package/types/router/directives/stateDirectives.d.ts +0 -3
  134. package/types/router/injectables.d.ts +0 -1
@@ -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
- if (
67
- !(
68
- button > 1 ||
69
- e.ctrlKey ||
70
- e.metaKey ||
71
- e.shiftKey ||
72
- e.altKey ||
73
- el.attr("target")
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: function (scope, element, attrs, uiSrefActive) {
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] = noop), acc),
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, noop);
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
- import { noop } from "../../shared/common";
4
+
5
5
  import { parse } from "../../shared/hof";
6
6
  import { ResolveContext } from "../resolve/resolveContext";
7
7
  import { trace } from "../common/trace";
@@ -143,18 +143,10 @@ export let uiView = [
143
143
  function getRenderer() {
144
144
  return {
145
145
  enter: function (element, target, cb) {
146
- // if (angular.version.minor > 2) {
147
- //$animate.enter(element, null, target).then(cb);
148
- // } else {
149
- $animate.enter(element, null, target, cb);
150
- // }
146
+ $animate.enter(element, null, target).then(cb);
151
147
  },
152
148
  leave: function (element, cb) {
153
- // if (angular.version.minor > 2) {
154
- //$animate.leave(element).then(cb);
155
- // } else {
156
- $animate.leave(element, cb);
157
- // }
149
+ $animate.leave(element).then(cb);
158
150
  },
159
151
  };
160
152
  }
@@ -273,7 +265,7 @@ export let uiView = [
273
265
  const cloned = $transclude(newScope, function (clone) {
274
266
  clone.data("$uiViewAnim", $uiViewAnim);
275
267
  clone.data("$uiView", $uiViewData);
276
- renderer.enter(clone, $element, function onUIViewEnter() {
268
+ renderer.enter(clone, $element, function () {
277
269
  animEnter.resolve();
278
270
  if (currentScope)
279
271
  currentScope.$emit("$viewContentAnimationEnded");
@@ -338,7 +330,7 @@ export function $ViewDirectiveFill(
338
330
  );
339
331
  return;
340
332
  }
341
- const cfg = data.$cfg || { viewDecl: {}, getTemplate: noop };
333
+ const cfg = data.$cfg || { viewDecl: {}, getTemplate: () => {} };
342
334
  const resolveCtx = cfg.path && new ResolveContext(cfg.path);
343
335
  $element.html(cfg.getTemplate($element, resolveCtx) || initial);
344
336
  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(noop);
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(noop);
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(noop);
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.all(enteringViews.map((view) => $q.when(view.load()))).then(noop);
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(noop);
88
+ this.defaultErrorHandler(() => {});
90
89
  this.invalidCallbacks = [];
91
90
  }
92
91
  /**
@@ -5,14 +5,20 @@ import { createProxyFunctions } from "../shared/common";
5
5
  import { minErr } from "../shared/utils";
6
6
 
7
7
  const err = minErr("$stateProvider");
8
+ // Right now this is a collection of all the properties we encounter in tests
8
9
  const validKeys = [
9
10
  "$$state",
10
11
  "__stateObjectCache",
12
+ "abstract",
13
+ "bindings",
11
14
  "controller",
15
+ "controllerAs",
12
16
  "controllerProvider",
13
17
  "component",
18
+ "componentProvider",
14
19
  "data",
15
20
  "includes",
21
+ "lazyLoad",
16
22
  "name",
17
23
  "navigable",
18
24
  "onEnter",
@@ -21,8 +27,10 @@ const validKeys = [
21
27
  "params",
22
28
  "parent",
23
29
  "path",
30
+ "redirectTo",
24
31
  "reloadOnSearch",
25
32
  "resolve",
33
+ "resolveAs",
26
34
  "resolvables",
27
35
  "self",
28
36
  "template",
@@ -10,15 +10,13 @@ import { kebobString } from "../shared/strings";
10
10
  */
11
11
  export class TemplateFactory {
12
12
  constructor() {
13
- /** @hidden */ this.$get = [
13
+ this._useHttp = false;
14
+ this.$get = [
14
15
  "$http",
15
16
  "$templateCache",
16
- "$injector",
17
- ($http, $templateCache, $injector) => {
18
- this.$templateRequest =
19
- $injector.has &&
20
- $injector.has("$templateRequest") &&
21
- $injector.get("$templateRequest");
17
+ "$templateRequest",
18
+ ($http, $templateCache, $templateRequest) => {
19
+ this.$templateRequest = $templateRequest;
22
20
  this.$http = $http;
23
21
  this.$templateCache = $templateCache;
24
22
  return this;
@@ -26,6 +24,14 @@ export class TemplateFactory {
26
24
  ];
27
25
  }
28
26
 
27
+ /**
28
+ * Forces the provider to use $http service directly
29
+ * @param {boolean} value
30
+ */
31
+ useHttpService(value) {
32
+ this._useHttp = value;
33
+ }
34
+
29
35
  /**
30
36
  * Creates a template from a configuration object.
31
37
  *
@@ -1,14 +1,14 @@
1
- var TransitionHookPhase;
2
- (function (TransitionHookPhase) {
3
- TransitionHookPhase[(TransitionHookPhase["CREATE"] = 0)] = "CREATE";
4
- TransitionHookPhase[(TransitionHookPhase["BEFORE"] = 1)] = "BEFORE";
5
- TransitionHookPhase[(TransitionHookPhase["RUN"] = 2)] = "RUN";
6
- TransitionHookPhase[(TransitionHookPhase["SUCCESS"] = 3)] = "SUCCESS";
7
- TransitionHookPhase[(TransitionHookPhase["ERROR"] = 4)] = "ERROR";
8
- })(TransitionHookPhase || (TransitionHookPhase = {}));
9
- var TransitionHookScope;
10
- (function (TransitionHookScope) {
11
- TransitionHookScope[(TransitionHookScope["TRANSITION"] = 0)] = "TRANSITION";
12
- TransitionHookScope[(TransitionHookScope["STATE"] = 1)] = "STATE";
13
- })(TransitionHookScope || (TransitionHookScope = {}));
14
- export { TransitionHookPhase, TransitionHookScope };
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
- /** An enum for Transition Rejection reasons */
5
- var RejectType;
6
- (function (RejectType) {
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
- RejectType[(RejectType["SUPERSEDED"] = 2)] = "SUPERSEDED";
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
- RejectType[(RejectType["ABORTED"] = 3)] = "ABORTED";
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
- RejectType[(RejectType["INVALID"] = 4)] = "INVALID";
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
- RejectType[(RejectType["IGNORED"] = 5)] = "IGNORED";
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
- RejectType[(RejectType["ERROR"] = 6)] = "ERROR";
43
- })(RejectType || (RejectType = {}));
44
- export { RejectType };
52
+ ERROR: 6,
53
+ };
45
54
 
46
55
  let id = 0;
47
56
  export class Rejection {
@@ -358,7 +358,11 @@ export class Transition {
358
358
  : new Resolvable(resolvable);
359
359
  const stateName = typeof state === "string" ? state : state.name;
360
360
  const topath = this._treeChanges.to;
361
- const targetNode = find(topath, (node) => node.state.name === stateName);
361
+ const targetNode = find(topath, (node) => {
362
+ return node.state.name === stateName;
363
+ });
364
+ console.assert(targetNode, `targetNode not found ${stateName}`);
365
+
362
366
  const resolveContext = new ResolveContext(topath);
363
367
  resolveContext.addResolvables([resolvable], targetNode.state);
364
368
  }
@@ -1,5 +1,5 @@
1
1
  import { TransitionHookPhase } from "./interface";
2
- import { defaults, noop, silentRejection } from "../../shared/common";
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: noop,
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, this.options);
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 = (hook) => (error) => silentRejection(error);
197
- TransitionHook.THROW_ERROR = (hook) => (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, options = {}) {
353
+ exec(path, search = {}, hash) {
355
354
  const match = memoizeTo(this._cache, "pattern", () => {
356
355
  return new RegExp(
357
356
  [
@@ -20,6 +20,13 @@ export class UrlRuleFactory {
20
20
  compile(str) {
21
21
  return this.router.urlMatcherFactory.compile(str);
22
22
  }
23
+
24
+ /**
25
+ *
26
+ * @param {*} what
27
+ * @param {*} handler
28
+ * @returns {BaseUrlRule}
29
+ */
23
30
  create(what, handler) {
24
31
  const { isState, isStateDeclaration } = StateObject;
25
32
  const makeRule = pattern([
@@ -193,13 +200,14 @@ UrlRuleFactory.isUrlRule = (obj) =>
193
200
  * A base rule which calls `match`
194
201
  *
195
202
  * The value from the `match` function is passed through to the `handler`.
196
- * @internal
203
+ * @type {angular.BaseUrlRule}
197
204
  */
198
205
  export class BaseUrlRule {
199
206
  constructor(match, handler) {
200
207
  this.match = match;
201
208
  this.type = "RAW";
202
- this.matchPriority = (match) => 0 - this.$id;
209
+ this.$id = -1;
210
+ this.matchPriority = () => 0 - this.$id;
203
211
  this.handler = handler || identity;
204
212
  }
205
213
  }
@@ -73,7 +73,7 @@ export class UrlRules {
73
73
  this.urlRuleFactory = new UrlRuleFactory(router);
74
74
  }
75
75
 
76
- dispose(router) {
76
+ dispose() {
77
77
  this._rules = [];
78
78
  delete this._otherwiseFn;
79
79
  }
@@ -5,18 +5,11 @@ import { forEach, isUndefined, equals } from "../shared/utils";
5
5
  // This variable should be used *only* inside the cacheState function.
6
6
  let lastCachedState = null;
7
7
 
8
- export function getHash(url) {
9
- const index = url.indexOf("#");
10
- return index === -1 ? "" : url.substr(index);
11
- }
12
-
13
8
  export function trimEmptyHash(url) {
14
9
  return url.replace(/#$/, "");
15
10
  }
16
11
 
17
12
  /**
18
- *
19
- *
20
13
  * @name $browser
21
14
  * @requires $log
22
15
  * @description
@@ -32,8 +25,6 @@ export function trimEmptyHash(url) {
32
25
  */
33
26
  export function Browser($log, $$taskTrackerFactory) {
34
27
  const self = this;
35
- let { location } = window;
36
- let { history } = window;
37
28
  const { setTimeout } = window;
38
29
  const { clearTimeout } = window;
39
30
  const pendingDeferIds = {};
@@ -56,10 +47,8 @@ export function Browser($log, $$taskTrackerFactory) {
56
47
 
57
48
  let cachedState;
58
49
  let lastHistoryState;
59
- let lastBrowserUrl = location.href;
60
- const baseElement = jqLite(
61
- Array.from(window.document.getElementsByTagName("base")),
62
- );
50
+ let lastBrowserUrl = window.location.href;
51
+ const baseElement = jqLite(Array.from(document.getElementsByTagName("base")));
63
52
  let pendingLocation = null;
64
53
  const getCurrentState = function getCurrentState() {
65
54
  return history.state;
@@ -96,10 +85,6 @@ export function Browser($log, $$taskTrackerFactory) {
96
85
  state = null;
97
86
  }
98
87
 
99
- // Android Browser BFCache causes location, history reference to become stale.
100
- if (location !== window.location) location = window.location;
101
- if (history !== window.history) history = window.history;
102
-
103
88
  // setter
104
89
  if (url) {
105
90
  const sameState = lastHistoryState === state;
@@ -129,7 +114,7 @@ export function Browser($log, $$taskTrackerFactory) {
129
114
  // - pendingLocation is needed as browsers don't allow to read out
130
115
  // the new location.href if a reload happened or if there is a bug like in iOS 9 (see
131
116
  // https://openradar.appspot.com/22186109).
132
- return trimEmptyHash(pendingLocation || location.href);
117
+ return trimEmptyHash(pendingLocation || window.location.href);
133
118
  };
134
119
 
135
120
  /**
@@ -20,7 +20,6 @@ export const equals = _equals;
20
20
  export function identity(x) {
21
21
  return x;
22
22
  }
23
- export function noop() {}
24
23
  /**
25
24
  * Builds proxy functions on the `to` object which pass through to the `from` object.
26
25
  *
@@ -6,21 +6,53 @@
6
6
  <script>
7
7
  document.addEventListener("DOMContentLoaded", () => {
8
8
  var myApp = window.angular.module("test", ["ui.router"]);
9
- myApp.config(function ($stateProvider) {
10
- var helloState = {
11
- name: "hello",
12
- url: "/",
13
- template: "<h3>hello world!</h3>",
14
- };
15
-
16
- $stateProvider.state(helloState);
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
- {{ 2 + 2 }}
23
- <a ui-sref="hello" ui-sref-active="active">Hello</a>
24
- <ui-view></ui-view>
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>