@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.
Files changed (128) hide show
  1. package/Makefile +1 -1
  2. package/README.md +3 -3
  3. package/TODO.md +14 -0
  4. package/dist/angular-ts.esm.js +1 -1
  5. package/dist/angular-ts.umd.js +1 -1
  6. package/index.html +2 -1
  7. package/package.json +1 -1
  8. package/src/animations/animate-css-driver.js +2 -2
  9. package/src/animations/animate-css.js +15 -6
  10. package/src/animations/animate-js.js +1 -1
  11. package/src/animations/animate-queue.js +1 -1
  12. package/src/animations/shared.js +0 -14
  13. package/src/core/compile.js +6 -3
  14. package/src/core/q.js +9 -9
  15. package/src/core/sanitize-uri.js +1 -1
  16. package/src/core/sce.js +1 -1
  17. package/src/directive/if.js +0 -79
  18. package/src/directive/if.md +80 -0
  19. package/src/directive/include.js +0 -82
  20. package/src/directive/include.md +86 -0
  21. package/src/directive/repeat.js +0 -1
  22. package/src/loader.js +0 -1
  23. package/src/public.js +0 -2
  24. package/src/router/common/trace.js +1 -1
  25. package/src/router/directives/stateDirectives.js +16 -14
  26. package/src/router/directives/viewDirective.js +2 -2
  27. package/src/router/hooks/resolve.js +3 -4
  28. package/src/router/hooks/views.js +3 -2
  29. package/src/router/state/stateService.js +1 -2
  30. package/src/router/transition/interface.js +14 -14
  31. package/src/router/transition/rejectFactory.js +29 -20
  32. package/src/router/transition/transitionHook.js +5 -5
  33. package/src/router/url/urlMatcher.js +1 -2
  34. package/src/router/url/urlRule.js +1 -1
  35. package/src/router/url/urlRules.js +1 -1
  36. package/src/shared/common.js +0 -1
  37. package/test/module-test.html +44 -12
  38. package/test/router/services.spec.js +71 -0
  39. package/test/router/state-directives.spec.js +1208 -0
  40. package/types/angular.d.ts +132 -124
  41. package/types/index.d.ts +2350 -2187
  42. package/types/jqlite.d.ts +463 -418
  43. package/types/router/core/common/common.d.ts +70 -24
  44. package/types/router/core/common/coreservices.d.ts +30 -32
  45. package/types/router/core/common/glob.d.ts +9 -9
  46. package/types/router/core/common/hof.d.ts +12 -4
  47. package/types/router/core/common/index.d.ts +8 -8
  48. package/types/router/core/common/predicates.d.ts +1 -1
  49. package/types/router/core/common/queue.d.ts +13 -13
  50. package/types/router/core/common/safeConsole.d.ts +3 -3
  51. package/types/router/core/common/strings.d.ts +4 -2
  52. package/types/router/core/common/trace.d.ts +94 -82
  53. package/types/router/core/globals.d.ts +37 -37
  54. package/types/router/core/hooks/coreResolvables.d.ts +5 -3
  55. package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
  56. package/types/router/core/hooks/invalidTransition.d.ts +4 -2
  57. package/types/router/core/hooks/lazyLoad.d.ts +10 -5
  58. package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
  59. package/types/router/core/hooks/redirectTo.d.ts +4 -2
  60. package/types/router/core/hooks/resolve.d.ts +10 -4
  61. package/types/router/core/hooks/updateGlobals.d.ts +4 -2
  62. package/types/router/core/hooks/url.d.ts +4 -2
  63. package/types/router/core/hooks/views.d.ts +7 -3
  64. package/types/router/core/index.d.ts +11 -12
  65. package/types/router/core/interface.d.ts +83 -81
  66. package/types/router/core/params/index.d.ts +5 -5
  67. package/types/router/core/params/interface.d.ts +439 -439
  68. package/types/router/core/params/param.d.ts +72 -60
  69. package/types/router/core/params/paramType.d.ts +40 -40
  70. package/types/router/core/params/paramTypes.d.ts +169 -165
  71. package/types/router/core/params/stateParams.d.ts +13 -13
  72. package/types/router/core/path/index.d.ts +2 -2
  73. package/types/router/core/path/pathNode.d.ts +49 -49
  74. package/types/router/core/path/pathUtils.d.ts +100 -74
  75. package/types/router/core/resolve/index.d.ts +3 -3
  76. package/types/router/core/resolve/interface.d.ts +137 -137
  77. package/types/router/core/resolve/resolvable.d.ts +60 -54
  78. package/types/router/core/resolve/resolveContext.d.ts +84 -79
  79. package/types/router/core/router.d.ts +95 -86
  80. package/types/router/core/state/index.d.ts +8 -8
  81. package/types/router/core/state/interface.d.ts +667 -643
  82. package/types/router/core/state/stateBuilder.d.ts +41 -38
  83. package/types/router/core/state/stateMatcher.d.ts +11 -9
  84. package/types/router/core/state/stateObject.d.ts +154 -139
  85. package/types/router/core/state/stateQueueManager.d.ts +26 -21
  86. package/types/router/core/state/stateRegistry.d.ts +124 -121
  87. package/types/router/core/state/stateService.d.ts +380 -343
  88. package/types/router/core/state/targetState.d.ts +74 -69
  89. package/types/router/core/transition/hookBuilder.d.ts +34 -30
  90. package/types/router/core/transition/hookRegistry.d.ts +96 -74
  91. package/types/router/core/transition/index.d.ts +8 -8
  92. package/types/router/core/transition/interface.d.ts +652 -609
  93. package/types/router/core/transition/rejectFactory.d.ts +97 -97
  94. package/types/router/core/transition/transition.d.ts +565 -517
  95. package/types/router/core/transition/transitionEventType.d.ts +20 -11
  96. package/types/router/core/transition/transitionHook.d.ts +90 -82
  97. package/types/router/core/transition/transitionService.d.ts +228 -161
  98. package/types/router/core/url/index.d.ts +8 -8
  99. package/types/router/core/url/interface.d.ts +100 -87
  100. package/types/router/core/url/urlConfig.d.ts +130 -126
  101. package/types/router/core/url/urlMatcher.d.ts +132 -127
  102. package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
  103. package/types/router/core/url/urlRouter.d.ts +91 -75
  104. package/types/router/core/url/urlRule.d.ts +123 -100
  105. package/types/router/core/url/urlRules.d.ts +240 -232
  106. package/types/router/core/url/urlService.d.ts +201 -201
  107. package/types/router/core/view/index.d.ts +2 -2
  108. package/types/router/core/view/interface.d.ts +26 -26
  109. package/types/router/core/view/view.d.ts +152 -143
  110. package/types/router/directives/viewDirective.d.ts +12 -11
  111. package/types/router/index.d.ts +11 -12
  112. package/types/router/interface.d.ts +361 -351
  113. package/types/router/legacy/resolveService.d.ts +44 -40
  114. package/types/router/legacy/stateEvents.d.ts +1 -1
  115. package/types/router/locationServices.d.ts +45 -37
  116. package/types/router/services.d.ts +9 -9
  117. package/types/router/stateFilters.d.ts +3 -3
  118. package/types/router/stateProvider.d.ts +240 -235
  119. package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
  120. package/types/router/statebuilders/views.d.ts +35 -22
  121. package/types/router/templateFactory.d.ts +99 -79
  122. package/types/router/viewScroll.d.ts +7 -7
  123. package/src/directive/a.js +0 -37
  124. package/test/directive/a.spec.js +0 -192
  125. package/types/router/angular.d.ts +0 -1
  126. package/types/router/core/vanilla.d.ts +0 -1
  127. package/types/router/directives/stateDirectives.d.ts +0 -3
  128. 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, transitionOptions) {
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
- 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";
@@ -338,7 +338,7 @@ export function $ViewDirectiveFill(
338
338
  );
339
339
  return;
340
340
  }
341
- const cfg = data.$cfg || { viewDecl: {}, getTemplate: noop };
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(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
  /**
@@ -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 {
@@ -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
  [
@@ -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 = (match) => 0 - this.$id;
202
+ this.matchPriority = () => 0 - this.$id;
203
203
  this.handler = handler || identity;
204
204
  }
205
205
  }
@@ -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
  }
@@ -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>
@@ -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
+ });