@angular-wave/angular.ts 0.0.67 → 0.0.69

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 (87) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-swap.js +1 -1
  5. package/src/core/animate/animate.js +5 -5
  6. package/src/core/compile/compile.spec.js +2 -2
  7. package/src/core/controller/controller.js +5 -1
  8. package/src/core/cookie-reader.spec.js +1 -1
  9. package/src/core/di/injector.js +1 -1
  10. package/src/core/di/injector.spec.js +35 -35
  11. package/src/core/di/internal-injector.js +1 -1
  12. package/src/core/filter/filter.spec.js +15 -15
  13. package/src/core/interpolate/interpolate.spec.js +29 -29
  14. package/src/core/interval/interval-factory.js +8 -1
  15. package/src/core/interval/interval.js +30 -16
  16. package/src/core/interval/interval.spec.js +1 -1
  17. package/src/core/location/location.js +473 -626
  18. package/src/core/location/location.md +114 -0
  19. package/src/core/location/location.spec.js +2 -77
  20. package/src/core/parser/lexer.spec.js +1 -1
  21. package/src/core/parser/parse.spec.js +1 -1
  22. package/src/core/q/q.js +64 -65
  23. package/src/core/q/q.spec.js +1 -1
  24. package/src/core/sce/sce.js +1 -3
  25. package/src/core/scope/scope.js +3 -6
  26. package/src/core/timeout/timeout.js +5 -21
  27. package/src/core/url-utils/url-utils.js +5 -0
  28. package/src/directive/attrs/boolean.spec.js +1 -1
  29. package/src/directive/bind/bind.js +2 -2
  30. package/src/directive/class/class.js +1 -1
  31. package/src/directive/form/form.js +1 -18
  32. package/src/directive/form/form.spec.js +2 -2
  33. package/src/directive/include/include.js +7 -0
  34. package/src/directive/input/input.js +1 -1
  35. package/src/{exts → directive}/messages/messages.html +4 -1
  36. package/src/directive/messages/messages.js +346 -0
  37. package/src/{exts → directive}/messages/messages.spec.js +7 -11
  38. package/src/{exts → directive}/messages/messages.test.js +1 -1
  39. package/src/directive/model-options/model-options.spec.js +1 -1
  40. package/src/directive/options/options.js +2 -156
  41. package/src/directive/options/options.md +179 -0
  42. package/src/directive/select/select.js +7 -4
  43. package/src/directive/switch/switch.spec.js +1 -1
  44. package/src/exts/aria/aria.spec.js +1 -1
  45. package/src/filters/filter.js +2 -3
  46. package/src/filters/filter.spec.js +1 -1
  47. package/src/filters/filters.spec.js +1 -1
  48. package/src/filters/limit-to.spec.js +2 -2
  49. package/src/loader.js +1 -1
  50. package/src/loader.spec.js +1 -1
  51. package/src/public.js +12 -2
  52. package/src/router/common/glob.spec.js +1 -1
  53. package/src/router/params/param-factory.js +1 -1
  54. package/src/router/params/param.js +54 -54
  55. package/src/router/path/path-utils.js +1 -0
  56. package/src/router/state/state-builder.spec.js +1 -1
  57. package/src/router/template-factory.js +6 -4
  58. package/src/router/url/url-service.js +7 -0
  59. package/src/router/view/view.spec.js +8 -11
  60. package/src/router/view-scroll.js +6 -1
  61. package/src/services/anchor-scroll.html +83 -0
  62. package/src/services/anchor-scroll.js +25 -10
  63. package/src/services/browser.js +1 -1
  64. package/src/services/http/http.spec.js +40 -40
  65. package/src/shared/jqlite/jqlite.js +4 -4
  66. package/src/shared/jqlite/jqlite.spec.js +4 -4
  67. package/src/shared/utils.js +1 -1
  68. package/types/core/interval/interval-factory.d.ts +1 -1
  69. package/types/core/interval/interval.d.ts +4 -0
  70. package/types/core/location/location.d.ts +235 -166
  71. package/types/core/q/q.d.ts +66 -40
  72. package/types/core/scope/scope.d.ts +5 -8
  73. package/types/core/timeout/timeout.d.ts +3 -7
  74. package/types/core/url-utils/url-utils.d.ts +4 -0
  75. package/types/directive/form/form.d.ts +3 -20
  76. package/types/directive/include/include.d.ts +1 -1
  77. package/types/router/params/param-factory.d.ts +1 -1
  78. package/types/router/params/param.d.ts +11 -0
  79. package/types/router/template-factory.d.ts +4 -4
  80. package/types/router/url/url-service.d.ts +9 -9
  81. package/types/router/view-scroll.d.ts +1 -1
  82. package/types/services/anchor-scroll.d.ts +16 -1
  83. package/types/services/browser.d.ts +2 -2
  84. package/types/shared/jqlite/jqlite.d.ts +2 -2
  85. package/src/exts/messages/messages.js +0 -359
  86. package/types/exts/messages/messages.d.ts +0 -1
  87. /package/src/{exts → directive}/messages/messages.md +0 -0
@@ -0,0 +1,179 @@
1
+ /\*\*
2
+
3
+ -
4
+ - The `ngOptions` attribute can be used to dynamically generate a list of `<option>`
5
+ - elements for the `<select>` element using the array or object obtained by evaluating the
6
+ - `ngOptions` comprehension expression.
7
+ -
8
+ - In many cases, {@link ng.directive:ngRepeat ngRepeat} can be used on `<option>` elements instead of
9
+ - `ngOptions` to achieve a similar result. However, `ngOptions` provides some benefits:
10
+ - - more flexibility in how the `<select>`'s model is assigned via the `select` **`as`** part of the
11
+ - comprehension expression
12
+ - - reduced memory consumption by not creating a new scope for each repeated instance
13
+ - - increased render speed by creating the options in a documentFragment instead of individually
14
+ -
15
+ - When an item in the `<select>` menu is selected, the array element or object property
16
+ - represented by the selected option will be bound to the model identified by the `ngModel`
17
+ - directive.
18
+ -
19
+ - Optionally, a single hard-coded `<option>` element, with the value set to an empty string, can
20
+ - be nested into the `<select>` element. This element will then represent the `null` or "not selected"
21
+ - option. See example below for demonstration.
22
+ -
23
+ - ## Complex Models (objects or collections)
24
+ -
25
+ - By default, `ngModel` watches the model by reference, not value. This is important to know when
26
+ - binding the select to a model that is an object or a collection.
27
+ -
28
+ - One issue occurs if you want to preselect an option. For example, if you set
29
+ - the model to an object that is equal to an object in your collection, `ngOptions` won't be able to set the selection,
30
+ - because the objects are not identical. So by default, you should always reference the item in your collection
31
+ - for preselections, e.g.: `$scope.selected = $scope.collection[3]`.
32
+ -
33
+ - Another solution is to use a `track by` clause, because then `ngOptions` will track the identity
34
+ - of the item not by reference, but by the result of the `track by` expression. For example, if your
35
+ - collection items have an id property, you would `track by item.id`.
36
+ -
37
+ - A different issue with objects or collections is that ngModel won't detect if an object property or
38
+ - a collection item changes. For that reason, `ngOptions` additionally watches the model using
39
+ - `$watchCollection`, when the expression contains a `track by` clause or the the select has the `multiple` attribute.
40
+ - This allows ngOptions to trigger a re-rendering of the options even if the actual object/collection
41
+ - has not changed identity, but only a property on the object or an item in the collection changes.
42
+ -
43
+ - Note that `$watchCollection` does a shallow comparison of the properties of the object (or the items in the collection
44
+ - if the model is an array). This means that changing a property deeper than the first level inside the
45
+ - object/collection will not trigger a re-rendering.
46
+ -
47
+ - ## `select` **`as`**
48
+ -
49
+ - Using `select` **`as`** will bind the result of the `select` expression to the model, but
50
+ - the value of the `<select>` and `<option>` html elements will be either the index (for array data sources)
51
+ - or property name (for object data sources) of the value within the collection. If a **`track by`** expression
52
+ - is used, the result of that expression will be set as the value of the `option` and `select` elements.
53
+ -
54
+ -
55
+ - ### `select` **`as`** and **`track by`**
56
+ -
57
+ - <div class="alert alert-warning">
58
+ - Be careful when using `select` **`as`** and **`track by`** in the same expression.
59
+ - </div>
60
+ -
61
+ - Given this array of items on the $scope:
62
+ -
63
+ - ```js
64
+
65
+ ```
66
+
67
+ - $scope.items = [{
68
+ - id: 1,
69
+ - label: 'aLabel',
70
+ - subItem: { name: 'aSubItem' }
71
+ - }, {
72
+ - id: 2,
73
+ - label: 'bLabel',
74
+ - subItem: { name: 'bSubItem' }
75
+ - }];
76
+ - ```
77
+
78
+ ```
79
+
80
+ -
81
+ - This will work:
82
+ -
83
+ - ```html
84
+
85
+ ```
86
+
87
+ - <select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>
88
+ - ```
89
+
90
+ ```
91
+
92
+ - ```js
93
+
94
+ ```
95
+
96
+ - $scope.selected = $scope.items[0];
97
+ - ```
98
+
99
+ ```
100
+
101
+ -
102
+ - but this will not work:
103
+ -
104
+ - ```html
105
+
106
+ ```
107
+
108
+ - <select ng-options="item.subItem as item.label for item in items track by item.id" ng-model="selected"></select>
109
+ - ```
110
+
111
+ ```
112
+
113
+ - ```js
114
+
115
+ ```
116
+
117
+ - $scope.selected = $scope.items[0].subItem;
118
+ - ```
119
+
120
+ ```
121
+
122
+ -
123
+ - In both examples, the **`track by`** expression is applied successfully to each `item` in the
124
+ - `items` array. Because the selected option has been set programmatically in the controller, the
125
+ - **`track by`** expression is also applied to the `ngModel` value. In the first example, the
126
+ - `ngModel` value is `items[0]` and the **`track by`** expression evaluates to `items[0].id` with
127
+ - no issue. In the second example, the `ngModel` value is `items[0].subItem` and the **`track by`**
128
+ - expression evaluates to `items[0].subItem.id` (which is undefined). As a result, the model value
129
+ - is not matched against any `<option>` and the `<select>` appears as having no selected value.
130
+ -
131
+ -
132
+ - @param {string} ngModel Assignable AngularJS expression to data-bind to.
133
+ - @param {string} ngOptions in one of the following forms:
134
+ -
135
+ - - for array data sources:
136
+ - * `label` **`for`** `value` **`in`** `array`
137
+ - * `select` **`as`** `label` **`for`** `value` **`in`** `array`
138
+ - * `label` **`group by`** `group` **`for`** `value` **`in`** `array`
139
+ - * `label` **`disable when`** `disable` **`for`** `value` **`in`** `array`
140
+ - * `label` **`group by`** `group` **`for`** `value` **`in`** `array` **`track by`** `trackexpr`
141
+ - * `label` **`disable when`** `disable` **`for`** `value` **`in`** `array` **`track by`** `trackexpr`
142
+ - * `label` **`for`** `value` **`in`** `array` | orderBy:`orderexpr` **`track by`** `trackexpr`
143
+ - (for including a filter with `track by`)
144
+ - - for object data sources:
145
+ - * `label` **`for (`**`key` **`,`** `value`**`) in`** `object`
146
+ - * `select` **`as`** `label` **`for (`**`key` **`,`** `value`**`) in`** `object`
147
+ - * `label` **`group by`** `group` **`for (`**`key`**`,`** `value`**`) in`** `object`
148
+ - * `label` **`disable when`** `disable` **`for (`**`key`**`,`** `value`**`) in`** `object`
149
+ - * `select` **`as`** `label` **`group by`** `group`
150
+ - **`for` `(`**`key`**`,`** `value`**`) in`** `object`
151
+ - * `select` **`as`** `label` **`disable when`** `disable`
152
+ - **`for` `(`**`key`**`,`** `value`**`) in`** `object`
153
+ -
154
+ - Where:
155
+ -
156
+ - - `array` / `object`: an expression which evaluates to an array / object to iterate over.
157
+ - - `value`: local variable which will refer to each item in the `array` or each property value
158
+ - of `object` during iteration.
159
+ - - `key`: local variable which will refer to a property name in `object` during iteration.
160
+ - - `label`: The result of this expression will be the label for `<option>` element. The
161
+ - `expression` will most likely refer to the `value` variable (e.g. `value.propertyName`).
162
+ - - `select`: The result of this expression will be bound to the model of the parent `<select>`
163
+ - element. If not specified, `select` expression will default to `value`.
164
+ - - `group`: The result of this expression will be used to group options using the `<optgroup>`
165
+ - DOM element.
166
+ - - `disable`: The result of this expression will be used to disable the rendered `<option>`
167
+ - element. Return `true` to disable.
168
+ - - `trackexpr`: Used when working with an array of objects. The result of this expression will be
169
+ - used to identify the objects in the array. The `trackexpr` will most likely refer to the
170
+ - `value` variable (e.g. `value.propertyName`). With this the selection is preserved
171
+ - even when the options are recreated (e.g. reloaded from the server).
172
+ - @param {string=} name Property name of the form under which the control is published.
173
+ - @param {string=} required The control is considered valid only if value is entered.
174
+ - @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
175
+ - the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
176
+ - `required` when you want to data-bind to the `required` attribute.
177
+ - @param {string=} ngAttrSize sets the size of the select element dynamically. Uses the
178
+ - {@link guide/interpolation#-ngattr-for-binding-to-arbitrary-attributes ngAttr} directive.
179
+ - \*/
@@ -8,8 +8,6 @@ import {
8
8
  shallowCopy,
9
9
  } from "../../shared/utils";
10
10
 
11
- const noopNgModelController = { $setViewValue: () => {}, $render: () => {} };
12
-
13
11
  function setOptionSelectedStatus(optionEl, value) {
14
12
  optionEl[0].selected = value;
15
13
  /**
@@ -29,6 +27,11 @@ function setOptionSelectedStatus(optionEl, value) {
29
27
  *
30
28
  */
31
29
  SelectController.$inject = ["$element", "$scope"];
30
+ /**
31
+ *
32
+ * @param {JQLite} $element
33
+ * @param {import('../../core/scope/scope').Scope} $scope
34
+ */
32
35
  function SelectController($element, $scope) {
33
36
  const self = this;
34
37
  const optionsMap = new Map();
@@ -36,7 +39,7 @@ function SelectController($element, $scope) {
36
39
  self.selectValueMap = {}; // Keys are the hashed values, values the original values
37
40
 
38
41
  // If the ngModel doesn't get provided then provide a dummy noop version to prevent errors
39
- self.ngModelCtrl = noopNgModelController;
42
+ self.ngModelCtrl = {};
40
43
  self.multiple = false;
41
44
 
42
45
  // The "unknown" option is one that is prepended to the list if the viewValue
@@ -101,7 +104,7 @@ function SelectController($element, $scope) {
101
104
 
102
105
  // Read the value of the select control, the implementation of this changes depending
103
106
  // upon whether the select can have multiple values and whether ngOptions is at work.
104
- self.readValue = function readSingleValue() {
107
+ self.readValue = function () {
105
108
  const val = $element.val();
106
109
  // ngValue added option values are stored in the selectValueMap, normal interpolations are not
107
110
  const realVal = val in self.selectValueMap ? self.selectValueMap[val] : val;
@@ -1,6 +1,6 @@
1
1
  import { Angular } from "../../loader";
2
2
  import { createInjector } from "../../core/di/injector";
3
- import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
3
+ import { dealoc } from "../../shared/jqlite/jqlite";
4
4
 
5
5
  describe("ngSwitch", () => {
6
6
  let $scope;
@@ -1,6 +1,6 @@
1
1
  import { createInjector } from "../../core/di/injector";
2
2
  import { Angular } from "../../loader";
3
- import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
3
+ import { dealoc } from "../../shared/jqlite/jqlite";
4
4
 
5
5
  describe("$aria", () => {
6
6
  let scope;
@@ -161,9 +161,8 @@ function deepCompare(
161
161
 
162
162
  switch (actualType) {
163
163
  case "object":
164
- var key;
165
164
  if (matchAgainstAnyProp) {
166
- for (key in actual) {
165
+ for (let key in actual) {
167
166
  // Under certain, rare, circumstances, key may not be a string and `charAt` will be undefined
168
167
  // See: https://github.com/angular/angular.js/issues/15644
169
168
  if (
@@ -179,7 +178,7 @@ function deepCompare(
179
178
  : deepCompare(actual, expected, comparator, anyPropertyKey, false);
180
179
  }
181
180
  if (expectedType === "object") {
182
- for (key in expected) {
181
+ for (let key in expected) {
183
182
  const expectedVal = expected[key];
184
183
  if (isFunction(expectedVal) || isUndefined(expectedVal)) {
185
184
  continue;
@@ -9,7 +9,7 @@ describe("Filter: filter", () => {
9
9
  beforeEach(() => {
10
10
  window.angular = new Angular();
11
11
  window.angular.module("myModule", ["ng"]);
12
- var injector = createInjector(["myModule"]);
12
+ const injector = createInjector(["myModule"]);
13
13
  filter = injector.get("$filter")("filter");
14
14
  });
15
15
 
@@ -8,7 +8,7 @@ describe("filters", () => {
8
8
  beforeEach(() => {
9
9
  window.angular = new Angular();
10
10
  window.angular.module("myModule", ["ng"]);
11
- var injector = createInjector(["myModule"]);
11
+ const injector = createInjector(["myModule"]);
12
12
  filter = injector.get("$filter");
13
13
  });
14
14
 
@@ -12,8 +12,8 @@ describe("Filter: limitTo", () => {
12
12
  beforeEach(() => {
13
13
  window.angular = new Angular();
14
14
  window.angular.module("myModule", ["ng"]);
15
- var injector = createInjector(["myModule"]);
16
- var $filter = injector.get("$filter");
15
+ const injector = createInjector(["myModule"]);
16
+ const $filter = injector.get("$filter");
17
17
 
18
18
  items = ["a", "b", "c", "d", "e", "f", "g", "h"];
19
19
  str = "tuvwxyz";
package/src/loader.js CHANGED
@@ -114,7 +114,7 @@ export class Angular {
114
114
  };
115
115
 
116
116
  this.doBootstrap = function () {
117
- var jqLite = JQLite(element);
117
+ const jqLite = JQLite(element);
118
118
 
119
119
  if (jqLite.injector()) {
120
120
  throw ngMinErr("btstrpd", "App already bootstrapped");
@@ -2,7 +2,7 @@ import { Angular } from "./loader";
2
2
  import { createInjector } from "./core/di/injector";
3
3
 
4
4
  describe("module loader", () => {
5
- var angular;
5
+ let angular;
6
6
  beforeEach(() => {
7
7
  angular = window.angular = new Angular();
8
8
  });
package/src/public.js CHANGED
@@ -90,7 +90,13 @@ import { TemplateRequestProvider } from "./services/template-request";
90
90
  import { $TimeoutProvider } from "./core/timeout/timeout";
91
91
  import { SanitizeUriProvider } from "./core/sanitize/sanitize-uri";
92
92
  import { initAnimateModule } from "./animations/module";
93
- import { initMessageModule } from "./exts/messages/messages";
93
+ import {
94
+ ngMessageDefaultDirective,
95
+ ngMessageDirective,
96
+ ngMessageExpDirective,
97
+ ngMessagesDirective,
98
+ ngMessagesIncludeDirective,
99
+ } from "./directive/messages/messages";
94
100
  import { initAriaModule } from "./exts/aria/aria";
95
101
  import { initRouter } from "./router/index";
96
102
 
@@ -139,6 +145,11 @@ export function publishExternalAPI(angular) {
139
145
  ngIf: ngIfDirective,
140
146
  ngInclude: ngIncludeDirective,
141
147
  ngInit: ngInitDirective,
148
+ ngMessages: ngMessagesDirective,
149
+ ngMessage: ngMessageDirective,
150
+ ngMessageExp: ngMessageExpDirective,
151
+ ngMessagesInclude: ngMessagesIncludeDirective,
152
+ ngMessageDefault: ngMessageDefaultDirective,
142
153
  ngNonBindable: ngNonBindableDirective,
143
154
  ngRef: ngRefDirective,
144
155
  ngRepeat: ngRepeatDirective,
@@ -207,7 +218,6 @@ export function publishExternalAPI(angular) {
207
218
  .info({ version: VERSION });
208
219
 
209
220
  initAnimateModule(angular);
210
- initMessageModule(angular);
211
221
  initAriaModule(angular);
212
222
  initRouter(angular);
213
223
  return ng;
@@ -1,4 +1,4 @@
1
- import { Glob } from "../../router/common/glob";
1
+ import { Glob } from "./glob";
2
2
 
3
3
  describe("Glob", function () {
4
4
  it("should match exact strings", function () {
@@ -1,4 +1,4 @@
1
- import { DefType, Param } from "../params/param";
1
+ import { DefType, Param } from "./param";
2
2
 
3
3
  export class ParamFactory {
4
4
  constructor(urlServiceConfig) {
@@ -86,47 +86,6 @@ function getReplace(config, arrayMode, isOptional, squash) {
86
86
  ).concat(replace);
87
87
  }
88
88
  export class Param {
89
- static values(params, values = {}) {
90
- const paramValues = {};
91
- for (const param of params) {
92
- paramValues[param.id] = param.value(values[param.id]);
93
- }
94
- return paramValues;
95
- }
96
- /**
97
- * Finds [[Param]] objects which have different param values
98
- *
99
- * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects
100
- *
101
- * @param params: The list of Param objects to filter
102
- * @param values1: The first set of parameter values
103
- * @param values2: the second set of parameter values
104
- *
105
- * @returns any Param objects whose values were different between values1 and values2
106
- */
107
- static changed(params, values1 = {}, values2 = {}) {
108
- return params.filter(
109
- (param) => !param.type.equals(values1[param.id], values2[param.id]),
110
- );
111
- }
112
- /**
113
- * Checks if two param value objects are equal (for a set of [[Param]] objects)
114
- *
115
- * @param params The list of [[Param]] objects to check
116
- * @param values1 The first set of param values
117
- * @param values2 The second set of param values
118
- *
119
- * @returns true if the param values in values1 and values2 are equal
120
- */
121
- static equals(params, values1 = {}, values2 = {}) {
122
- return Param.changed(params, values1, values2).length === 0;
123
- }
124
- /** Returns true if a the parameter values are valid, according to the Param definitions */
125
- static validates(params, values = {}) {
126
- return params
127
- .map((param) => param.validates(values[param.id]))
128
- .reduce(allTrueR, true);
129
- }
130
89
  constructor(id, type, location, urlConfig, state) {
131
90
  const config = getParamDeclaration(id, location, state);
132
91
  type = getType(config, type, location, id, urlConfig.paramTypes);
@@ -157,20 +116,19 @@ export class Param {
157
116
  const arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {};
158
117
  return Object.assign(arrayDefaults, arrayParamNomenclature, config).array;
159
118
  }
160
- Object.assign(this, {
161
- id,
162
- type,
163
- location,
164
- isOptional,
165
- dynamic,
166
- raw,
167
- squash,
168
- replace,
169
- inherit,
170
- array: arrayMode,
171
- config,
172
- });
119
+ this.isOptional = isOptional;
120
+ this.type = type;
121
+ this.location = location;
122
+ this.id = id;
123
+ this.dynamic = dynamic;
124
+ this.raw = raw;
125
+ this.squash = squash;
126
+ this.replace = replace;
127
+ this.inherit = inherit;
128
+ this.array = arrayMode;
129
+ this.config = config;
173
130
  }
131
+
174
132
  isDefaultValue(value) {
175
133
  return this.isOptional && this.type.equals(this.value(), value);
176
134
  }
@@ -227,4 +185,46 @@ export class Param {
227
185
  toString() {
228
186
  return `{Param:${this.id} ${this.type} squash: '${this.squash}' optional: ${this.isOptional}}`;
229
187
  }
188
+
189
+ static values(params, values = {}) {
190
+ const paramValues = {};
191
+ for (const param of params) {
192
+ paramValues[param.id] = param.value(values[param.id]);
193
+ }
194
+ return paramValues;
195
+ }
196
+ /**
197
+ * Finds [[Param]] objects which have different param values
198
+ *
199
+ * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects
200
+ *
201
+ * @param params: The list of Param objects to filter
202
+ * @param values1: The first set of parameter values
203
+ * @param values2: the second set of parameter values
204
+ *
205
+ * @returns any Param objects whose values were different between values1 and values2
206
+ */
207
+ static changed(params, values1 = {}, values2 = {}) {
208
+ return params.filter(
209
+ (param) => !param.type.equals(values1[param.id], values2[param.id]),
210
+ );
211
+ }
212
+ /**
213
+ * Checks if two param value objects are equal (for a set of [[Param]] objects)
214
+ *
215
+ * @param params The list of [[Param]] objects to check
216
+ * @param values1 The first set of param values
217
+ * @param values2 The second set of param values
218
+ *
219
+ * @returns true if the param values in values1 and values2 are equal
220
+ */
221
+ static equals(params, values1 = {}, values2 = {}) {
222
+ return Param.changed(params, values1, values2).length === 0;
223
+ }
224
+ /** Returns true if a the parameter values are valid, according to the Param definitions */
225
+ static validates(params, values = {}) {
226
+ return params
227
+ .map((param) => param.validates(values[param.id]))
228
+ .reduce(allTrueR, true);
229
+ }
230
230
  }
@@ -74,6 +74,7 @@ export class PathUtils {
74
74
  */
75
75
  static inheritParams(fromPath, toPath, toKeys = []) {
76
76
  function nodeParamVals(path, state) {
77
+ /** @type {PathNode} */
77
78
  const node = find(path, propEq("state", state));
78
79
  return Object.assign({}, node && node.paramValues);
79
80
  }
@@ -1,4 +1,4 @@
1
- import { StateBuilder } from "../../router/state/state-builder";
1
+ import { StateBuilder } from "./state-builder";
2
2
 
3
3
  // TODO refactor this to url service
4
4
  xdescribe("StateBuilder", function () {
@@ -111,7 +111,9 @@ export class TemplateFactory {
111
111
  * string.
112
112
  */
113
113
  fromString(template, params) {
114
- return isFunction(template) ? template(params) : template;
114
+ return isFunction(template)
115
+ ? /** @type {Function} */ (template)(params)
116
+ : template;
115
117
  }
116
118
  /**
117
119
  * Loads a template from the a URL via `$http` and `$templateCache`.
@@ -123,7 +125,7 @@ export class TemplateFactory {
123
125
  * for that string.
124
126
  */
125
127
  fromUrl(url, params) {
126
- if (isFunction(url)) url = url(params);
128
+ if (isFunction(url)) url = /** @type {Function} */ (url)(params);
127
129
  if (url == null) return null;
128
130
  if (this._useHttp) {
129
131
  return this.$http
@@ -141,7 +143,7 @@ export class TemplateFactory {
141
143
  * Creates a template by invoking an injectable provider function.
142
144
  *
143
145
  * @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
144
- * @param {Function} injectFn a function used to invoke the template provider
146
+ * @param {Function} params a function used to invoke the template provider
145
147
  * @param {import("./resolve/resolve-context").ResolveContext} context
146
148
  * @return {string|Promise.<string>} The template html as a string, or a promise
147
149
  * for that string.
@@ -156,7 +158,7 @@ export class TemplateFactory {
156
158
  * Creates a component's template by invoking an injectable provider function.
157
159
  *
158
160
  * @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
159
- * @param {Function} injectFn a function used to invoke the template provider
161
+ * @param {Function} params a function used to invoke the template provider
160
162
  * @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
161
163
  */
162
164
  fromComponentProvider(provider, params, context) {
@@ -92,6 +92,13 @@ export class UrlService {
92
92
  "$location",
93
93
  "$browser",
94
94
  "$rootScope",
95
+ /**
96
+ *
97
+ * @param {import('../../core/location/location').Location} $location
98
+ * @param {import('../../services/browser').Browser} $browser
99
+ * @param {import('../../core/scope/scope').Scope} $rootScope
100
+ * @returns
101
+ */
95
102
  ($location, $browser, $rootScope) => {
96
103
  this.$location = $location;
97
104
  this.$browser = $browser;
@@ -1,16 +1,13 @@
1
- import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
1
+ import { dealoc } from "../../shared/jqlite/jqlite";
2
2
  import { Angular } from "../../loader";
3
3
  import { curry } from "../../shared/hof";
4
- import { StateMatcher } from "../../router/state/state-matcher";
5
- import { StateBuilder } from "../../router/state/state-builder";
6
- import { StateObject } from "../../router/state/state-object";
7
- import { ViewService } from "../../router/view/view";
8
- import {
9
- ng1ViewsBuilder,
10
- getNg1ViewConfigFactory,
11
- } from "../../router/state/views";
12
- import { PathNode } from "../../router/path/path-node";
13
- import { PathUtils } from "../../router/path/path-utils";
4
+ import { StateMatcher } from "../state/state-matcher";
5
+ import { StateBuilder } from "../state/state-builder";
6
+ import { StateObject } from "../state/state-object";
7
+ import { ViewService } from "./view.js";
8
+ import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "../state/views.js";
9
+ import { PathNode } from "../path/path-node";
10
+ import { PathUtils } from "../path/path-utils";
14
11
  import { tail } from "../../shared/common";
15
12
  import { wait } from "../../shared/test-utils";
16
13
 
@@ -6,7 +6,12 @@ export function $ViewScrollProvider() {
6
6
  this.$get = [
7
7
  "$anchorScroll",
8
8
  "$timeout",
9
- function ($anchorScroll, $timeout) {
9
+ /**
10
+ * @param {import('../services/anchor-scroll').AnchorScrollObject} $anchorScroll
11
+ * @param {*} $timeout
12
+ * @returns {import('../services/anchor-scroll').AnchorScrollObject|Function}
13
+ */
14
+ ($anchorScroll, $timeout) => {
10
15
  if (useAnchorScroll) {
11
16
  return $anchorScroll;
12
17
  }