@angular-wave/angular.ts 0.9.2 → 0.9.4

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 (196) hide show
  1. package/@types/angular.d.ts +4 -19
  2. package/@types/animations/animate.d.ts +2 -2
  3. package/@types/animations/animation.d.ts +1 -1
  4. package/@types/core/compile/attributes.d.ts +1 -1
  5. package/@types/core/compile/compile.d.ts +2 -2
  6. package/@types/core/controller/controller.d.ts +1 -1
  7. package/@types/core/controller/interface.d.ts +6 -0
  8. package/@types/core/di/ng-module.d.ts +27 -26
  9. package/@types/core/filter/filter.d.ts +5 -5
  10. package/@types/core/interpolate/interface.d.ts +13 -0
  11. package/@types/core/interpolate/interpolate.d.ts +1 -13
  12. package/@types/core/scope/scope.d.ts +4 -1
  13. package/@types/directive/http/http.d.ts +16 -16
  14. package/@types/directive/http/interface.d.ts +27 -0
  15. package/@types/directive/include/include.d.ts +4 -4
  16. package/@types/directive/inject/inject.d.ts +12 -0
  17. package/@types/directive/model/model.d.ts +1 -1
  18. package/@types/directive/script/script.d.ts +2 -2
  19. package/@types/directive/setter/setter.d.ts +4 -4
  20. package/@types/filters/filter.d.ts +2 -2
  21. package/@types/filters/filters.d.ts +2 -2
  22. package/@types/filters/interface.d.ts +8 -0
  23. package/@types/filters/limit-to.d.ts +2 -2
  24. package/@types/filters/order-by.d.ts +2 -2
  25. package/@types/index.d.ts +84 -1
  26. package/@types/interface.d.ts +105 -82
  27. package/@types/router/state/interface.d.ts +8 -8
  28. package/@types/router/state-filters.d.ts +4 -4
  29. package/@types/router/template-factory.d.ts +6 -6
  30. package/@types/router/transition/hook-builder.d.ts +5 -2
  31. package/@types/router/transition/hook-registry.d.ts +11 -2
  32. package/@types/router/transition/transition-service.d.ts +6 -2
  33. package/@types/router/transition/transition.d.ts +2 -2
  34. package/@types/router/view/view.d.ts +1 -8
  35. package/@types/router/view-scroll.d.ts +4 -2
  36. package/@types/services/{anchor-scroll.d.ts → anchor-scroll/anchor-scroll.d.ts} +2 -2
  37. package/@types/services/exception/exception-handler.d.ts +2 -2
  38. package/@types/services/exception/interface.d.ts +1 -1
  39. package/@types/services/http/http.d.ts +40 -2
  40. package/@types/services/http/interface.d.ts +11 -0
  41. package/@types/services/location/location.d.ts +1 -4
  42. package/@types/services/sce/sce.d.ts +3 -4
  43. package/@types/services/template-cache/template-cache.d.ts +4 -4
  44. package/@types/services/template-request/interface.d.ts +22 -0
  45. package/@types/services/{template-request.d.ts → template-request/template-request.d.ts} +4 -7
  46. package/@types/shared/common.d.ts +8 -69
  47. package/@types/shared/hof.d.ts +7 -7
  48. package/dist/angular-ts.esm.js +509 -570
  49. package/dist/angular-ts.umd.js +509 -570
  50. package/dist/angular-ts.umd.min.js +1 -1
  51. package/{src/filters → docs/content/docs/filter}/filter.md +18 -9
  52. package/{src/filters → docs/content/docs/filter}/json.md +6 -3
  53. package/docs/content/docs/filter/limit-to.md +30 -0
  54. package/docs/content/docs/filter/order-by.md +123 -0
  55. package/docs/content/docs/provider/sceProvider.md +194 -0
  56. package/docs/content/docs/provider/templateRequestProvider.md +5 -0
  57. package/docs/content/docs/service/compile.md +5 -0
  58. package/docs/content/docs/service/controller.md +5 -0
  59. package/docs/content/docs/service/http.md +161 -0
  60. package/docs/content/docs/service/interpolation.md +5 -0
  61. package/docs/content/docs/service/log.md +1 -1
  62. package/docs/content/docs/service/parse.md +5 -0
  63. package/docs/content/docs/service/rootElement.md +5 -0
  64. package/docs/content/docs/service/rootScope.md +5 -0
  65. package/docs/content/docs/service/sce.md +194 -0
  66. package/docs/content/docs/service/templateRequest.md +5 -0
  67. package/docs/content/docs/values/_index.md +4 -0
  68. package/docs/content/docs/values/document.md +29 -0
  69. package/docs/content/docs/values/window.md +29 -0
  70. package/docs/layouts/shortcodes/version.html +1 -1
  71. package/docs/static/examples/document/document.html +3 -0
  72. package/docs/static/examples/i18n/i18n.html +77 -0
  73. package/docs/static/examples/window/window.html +4 -0
  74. package/docs/static/typedoc/assets/hierarchy.js +1 -1
  75. package/docs/static/typedoc/assets/highlight.css +0 -49
  76. package/docs/static/typedoc/assets/navigation.js +1 -1
  77. package/docs/static/typedoc/assets/search.js +1 -1
  78. package/docs/static/typedoc/classes/PubSubProvider.html +3 -2
  79. package/docs/static/typedoc/classes/TemplateCacheProvider.html +1 -1
  80. package/docs/static/typedoc/hierarchy.html +1 -1
  81. package/docs/static/typedoc/index.html +1 -1
  82. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +1 -1
  83. package/docs/static/typedoc/interfaces/RequestConfig.html +1 -1
  84. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +1 -1
  85. package/docs/static/typedoc/interfaces/ServiceProvider.html +3 -3
  86. package/docs/static/typedoc/types/HttpParamSerializer.html +2 -0
  87. package/docs/static/typedoc/types/{Expression.html → HttpParams.html} +1 -5
  88. package/legacy.d.ts +0 -921
  89. package/package.json +1 -1
  90. package/src/angular.js +2 -9
  91. package/src/animations/animate.js +1 -1
  92. package/src/animations/animation.js +7 -7
  93. package/src/core/compile/compile.js +3 -2
  94. package/src/core/controller/controller.js +10 -6
  95. package/src/core/controller/interface.ts +6 -0
  96. package/src/core/di/injector.js +1 -1
  97. package/src/core/di/internal-injector.js +2 -0
  98. package/src/core/di/ng-module.js +16 -13
  99. package/src/core/filter/filter.js +3 -3
  100. package/src/core/interpolate/interface.ts +14 -0
  101. package/src/core/interpolate/interpolate.js +7 -5
  102. package/src/core/scope/scope.js +4 -1
  103. package/src/directive/http/delete.spec.js +5 -8
  104. package/src/directive/http/http.js +16 -16
  105. package/src/directive/http/interface.ts +36 -0
  106. package/src/directive/http/put.spec.js +5 -8
  107. package/src/directive/include/include.js +2 -2
  108. package/src/{services/http-backend/http-backend.html → directive/inject/inject.html} +1 -4
  109. package/src/directive/inject/inject.js +35 -0
  110. package/src/directive/inject/inject.spec.js +108 -0
  111. package/src/{services/http-backend/http-backend.test.js → directive/inject/inject.test.js} +1 -1
  112. package/src/directive/script/script.js +1 -1
  113. package/src/directive/setter/setter.js +2 -2
  114. package/src/filters/filter.js +1 -1
  115. package/src/filters/filters.js +1 -1
  116. package/src/filters/interface.ts +9 -0
  117. package/src/filters/limit-to.js +1 -1
  118. package/src/filters/order-by.js +1 -1
  119. package/src/index.ts +96 -0
  120. package/src/injection-tokens.js +4 -1
  121. package/src/interface.ts +102 -93
  122. package/src/ng.js +6 -4
  123. package/src/ng.spec.js +12 -0
  124. package/src/router/directives/state-directives.js +1 -1
  125. package/src/router/directives/view-directive.spec.js +19 -35
  126. package/src/router/state/interface.ts +8 -8
  127. package/src/router/state/state-builder.js +4 -4
  128. package/src/router/state/state-registry.js +7 -2
  129. package/src/router/state/state-service.js +2 -14
  130. package/src/router/state-filters.js +2 -2
  131. package/src/router/template-factory.js +3 -3
  132. package/src/router/template-factory.spec.js +10 -19
  133. package/src/router/transition/hook-builder.js +5 -1
  134. package/src/router/transition/hook-registry.js +12 -3
  135. package/src/router/transition/transition-service.js +4 -9
  136. package/src/router/transition/transition.js +3 -2
  137. package/src/router/url/url-service.js +2 -2
  138. package/src/router/view/view.js +3 -15
  139. package/src/router/view-scroll.js +2 -2
  140. package/src/services/{anchor-scroll.js → anchor-scroll/anchor-scroll.js} +4 -4
  141. package/src/services/exception/exception-handler.js +1 -1
  142. package/src/services/exception/interface.ts +1 -1
  143. package/src/services/http/http.js +200 -13
  144. package/src/services/http/http.spec.js +388 -9
  145. package/src/services/http/interface.ts +13 -0
  146. package/src/services/location/location.js +1 -1
  147. package/src/services/pubsub/pubsub.js +0 -1
  148. package/src/services/sce/sce.js +18 -13
  149. package/src/services/template-cache/template-cache.js +2 -2
  150. package/src/services/template-request/interface.ts +23 -0
  151. package/src/services/{template-request.js → template-request/template-request.js} +6 -6
  152. package/src/shared/common.js +7 -80
  153. package/src/shared/hof.js +23 -17
  154. package/typedoc.json +1 -1
  155. package/@types/services/cookie-reader.d.ts +0 -4
  156. package/@types/services/http-backend/http-backend.d.ts +0 -58
  157. package/@types/services/template-cache/interface.d.ts +0 -10
  158. package/docs/static/typedoc/interfaces/ChangesObject.html +0 -6
  159. package/docs/static/typedoc/interfaces/ComponentOptions.html +0 -16
  160. package/docs/static/typedoc/interfaces/Controller.html +0 -12
  161. package/docs/static/typedoc/interfaces/Directive.html +0 -37
  162. package/docs/static/typedoc/interfaces/DirectivePrePost.html +0 -4
  163. package/docs/static/typedoc/interfaces/NgModelController.html +0 -30
  164. package/docs/static/typedoc/interfaces/NgModelOptions.html +0 -16
  165. package/docs/static/typedoc/interfaces/Provider.html +0 -34
  166. package/docs/static/typedoc/interfaces/TemplateCache.html +0 -7
  167. package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +0 -8
  168. package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +0 -1
  169. package/docs/static/typedoc/types/AnnotatedFactory.html +0 -8
  170. package/docs/static/typedoc/types/CloneAttachFunction.html +0 -2
  171. package/docs/static/typedoc/types/ControllerConstructor.html +0 -2
  172. package/docs/static/typedoc/types/DirectiveCompileFn.html +0 -2
  173. package/docs/static/typedoc/types/DirectiveController.html +0 -2
  174. package/docs/static/typedoc/types/DirectiveFactory.html +0 -1
  175. package/docs/static/typedoc/types/DirectiveFactoryFn.html +0 -1
  176. package/docs/static/typedoc/types/DirectiveLinkFn.html +0 -2
  177. package/docs/static/typedoc/types/ExpandoStore.html +0 -2
  178. package/docs/static/typedoc/types/FilterFactory.html +0 -2
  179. package/docs/static/typedoc/types/FilterFn.html +0 -2
  180. package/docs/static/typedoc/types/Injectable.html +0 -4
  181. package/docs/static/typedoc/types/InjectableClass.html +0 -1
  182. package/docs/static/typedoc/types/InjectableFactory.html +0 -1
  183. package/docs/static/typedoc/types/OnChangesObject.html +0 -2
  184. package/docs/static/typedoc/types/SwapModeType.html +0 -2
  185. package/docs/static/typedoc/types/TController.html +0 -2
  186. package/docs/static/typedoc/variables/SwapMode.html +0 -11
  187. package/src/filters/limit-to.md +0 -19
  188. package/src/filters/order-by.md +0 -83
  189. package/src/router/state/README.md +0 -21
  190. package/src/services/cookie-reader.js +0 -48
  191. package/src/services/http/http.md +0 -413
  192. package/src/services/http-backend/http-backend.js +0 -158
  193. package/src/services/http-backend/http-backend.spec.js +0 -389
  194. package/src/services/sce/sce.md +0 -300
  195. package/src/services/template-cache/interface.ts +0 -10
  196. /package/src/services/{anchor-scroll.html → anchor-scroll/anchor-scroll.html} +0 -0
@@ -9,19 +9,23 @@
9
9
  -
10
10
  - @param {Array} array The source array.
11
11
  - <div class="alert alert-info">
12
- - **Note**: If the array contains objects that reference themselves, filtering is not possible.
12
+ - **Note**: If the array contains objects that reference themselves, filtering
13
+ is not possible.
13
14
  - </div>
14
- - @param {string|Object|function()} expression The predicate to be used for selecting items from
15
+ - @param {string|Object|function()} expression The predicate to be used for
16
+ selecting items from
15
17
  - `array`.
16
18
  -
17
19
  - Can be one of:
18
20
  -
19
- - - `string`: The string is used for matching against the contents of the `array`. All strings or
21
+ - - `string`: The string is used for matching against the contents of the
22
+ `array`. All strings or
20
23
  - objects with string properties in `array` that match this string will be returned. This also
21
24
  - applies to nested object properties.
22
25
  - The predicate can be negated by prefixing the string with `!`.
23
26
  -
24
- - - `Object`: A pattern object can be used to filter specific properties on objects contained
27
+ - - `Object`: A pattern object can be used to filter specific properties on
28
+ objects contained
25
29
  - by `array`. For example `{name:"M", phone:"1"}` predicate will return an array of items
26
30
  - which have property `name` containing "M" and property `phone` containing "1". A special
27
31
  - property name (`$` by default) can be used (e.g. as in `{$: "text"}`) to accept a match
@@ -37,13 +41,15 @@
37
41
  - `{name: {first: 'John', last: 'Doe'}}` will **not** be matched by `{name: 'John'}`, but
38
42
  - **will** be matched by `{$: 'John'}`.
39
43
  -
40
- - - `function(value, index, array)`: A predicate function can be used to write arbitrary filters.
44
+ - - `function(value, index, array)`: A predicate function can be used to write
45
+ arbitrary filters.
41
46
  - The function is called for each element of the array, with the element, its index, and
42
47
  - the entire array itself as arguments.
43
48
  -
44
49
  - The final result is an array of those elements that the predicate returned true for.
45
50
  -
46
- - @param {function(actual, expected)|true|false} [comparator] Comparator which is used in
51
+ - @param {function(actual, expected)|true|false} [comparator] Comparator which
52
+ is used in
47
53
  - determining if values retrieved using `expression` (when it is not a function) should be
48
54
  - considered a match based on the expected value (from the filter expression) and actual
49
55
  - value (from the object in the array).
@@ -54,16 +60,19 @@
54
60
  - The function will be given the object value and the predicate value to compare and
55
61
  - should return true if both values should be considered equal.
56
62
  -
57
- - - `true`: A shorthand for `function(actual, expected) { return angular.equals(actual, expected)}`.
63
+ - - `true`: A shorthand for
64
+ `function(actual, expected) { return angular.equals(actual, expected)}`.
58
65
  - This is essentially strict comparison of expected and actual.
59
66
  -
60
- - - `false`: A short hand for a function which will look for a substring match in a case
67
+ - - `false`: A short hand for a function which will look for a substring match
68
+ in a case
61
69
  - insensitive way. Primitive values are converted to strings. Objects are not compared against
62
70
  - primitives, unless they have a custom `toString` method (e.g. `Date` objects).
63
71
  -
64
72
  -
65
73
  - Defaults to `false`.
66
74
  -
67
- - @param {string} [anyPropertyKey] The special property name that matches against any property.
75
+ - @param {string} [anyPropertyKey] The special property name that matches
76
+ against any property.
68
77
  - By default `$`.
69
78
  - \*/
@@ -4,12 +4,15 @@
4
4
 
5
5
  Allows you to convert a JavaScript object into a JSON string.
6
6
 
7
- This filter is mostly useful for debugging. When using the double curly `{{value}}` notation, the binding is automatically converted to JSON.
7
+ This filter is mostly useful for debugging. When using the double curly
8
+ `{{value}}` notation, the binding is automatically converted to JSON.
8
9
 
9
10
  ## Parameters
10
11
 
11
- - **object** `{*}`: Any JavaScript object (including arrays and primitive types) to filter.
12
- - **spacing** `{number=}`: The number of spaces to use per indentation, defaults to 2.
12
+ - **object** `{*}`: Any JavaScript object (including arrays and primitive types)
13
+ to filter.
14
+ - **spacing** `{number=}`: The number of spaces to use per indentation, defaults
15
+ to 2.
13
16
 
14
17
  ## Returns
15
18
 
@@ -0,0 +1,30 @@
1
+ # limitTo Filter
2
+
3
+ ## Description
4
+
5
+ Creates a new array or string containing only a specified number of elements.
6
+ The elements are taken from either the beginning or the end of the source array,
7
+ string, or number, as specified by the value and sign (positive or negative) of
8
+ `limit`. Other array-like objects are also supported (e.g., array subclasses,
9
+ NodeLists, JQLite/jQuery collections, etc.). If a number is used as input, it is
10
+ converted to a string.
11
+
12
+ ## Parameters
13
+
14
+ - **input** `{Array|ArrayLike|string|number}`: Array/array-like, string, or
15
+ number to be limited.
16
+ - **limit** `{string|number}`: The length of the returned array or string.
17
+ - If the `limit` number is positive, `limit` number of items from the
18
+ beginning of the source array/string are copied.
19
+ - If the number is negative, `limit` number of items from the end of the
20
+ source array/string are copied.
21
+ - The `limit` will be trimmed if it exceeds `array.length`.
22
+ - If `limit` is undefined, the input will be returned unchanged.
23
+ - **begin** `{(string|number)=}`: Index at which to begin limitation. As a
24
+ negative index, `begin` indicates an offset from the end of `input`. Defaults
25
+ to `0`.
26
+
27
+ ## Returns
28
+
29
+ - `{Array|string}`: A new sub-array or substring of length `limit` or less if
30
+ the input had less than `limit` elements.
@@ -0,0 +1,123 @@
1
+ # OrderBy Filter
2
+
3
+ ## Description
4
+
5
+ Returns an array containing the items from the specified `collection`, ordered
6
+ by a `comparator` function based on the values computed using the `expression`
7
+ predicate.
8
+
9
+ For example, `[{id: 'foo'}, {id: 'bar'}] | orderBy:'id'` would result in
10
+ `[{id: 'bar'}, {id: 'foo'}]`.
11
+
12
+ The `collection` can be an Array or array-like object (e.g., NodeList, jQuery
13
+ object, TypedArray, String, etc).
14
+
15
+ The `expression` can be a single predicate or a list of predicates, each serving
16
+ as a tie-breaker for the preceding one. The `expression` is evaluated against
17
+ each item and the output is used for comparing with other items.
18
+
19
+ You can change the sorting order by setting `reverse` to `true`. By default,
20
+ items are sorted in ascending order.
21
+
22
+ The comparison is done using the `comparator` function. If none is specified, a
23
+ default, built-in comparator is used (see below for details - in a nutshell, it
24
+ compares numbers numerically and strings alphabetically).
25
+
26
+ ### Under the Hood
27
+
28
+ Ordering the specified `collection` happens in two phases:
29
+
30
+ 1. All items are passed through the predicate (or predicates), and the returned
31
+ values are saved along with their type (`string`, `number`, etc). For
32
+ example, an item `{label: 'foo'}`, passed through a predicate that extracts
33
+ the value of the `label` property, would be transformed to:
34
+ ```javascript
35
+ {
36
+ value: 'foo',
37
+ type: 'string',
38
+ index: ...
39
+ }
40
+ ```
41
+
42
+ Note: null values use 'null' as their type. 2. The comparator function is used
43
+ to sort the items, based on the derived values, types, and indices.
44
+
45
+ If you use a custom comparator, it will be called with pairs of objects of the
46
+ form {value: ..., type: '...', index: ...} and is expected to return 0 if the
47
+ objects are equal (as far as the comparator is concerned), -1 if the 1st one
48
+ should be ranked higher than the second, or 1 otherwise.
49
+
50
+ To ensure that the sorting will be deterministic across platforms, if none of
51
+ the specified predicates can distinguish between two items, orderBy will
52
+ automatically introduce a dummy predicate that returns the item's index as
53
+ value. (If you are using a custom comparator, make sure it can handle this
54
+ predicate as well.)
55
+
56
+ If a custom comparator still can't distinguish between two items, then they will
57
+ be sorted based on their index using the built-in comparator.
58
+
59
+ Finally, in an attempt to simplify things, if a predicate returns an object as
60
+ the extracted value for an item, orderBy will try to convert that object to a
61
+ primitive value before passing it to the comparator. The following rules govern
62
+ the conversion:
63
+
64
+ If the object has a valueOf() method that returns a primitive, its return value
65
+ will be used instead. (If the object has a valueOf() method that returns another
66
+ object, then the returned object will be used in subsequent steps.) If the
67
+ object has a custom toString() method (i.e., not the one inherited from Object)
68
+ that returns a primitive, its return value will be used instead. (If the object
69
+ has a toString() method that returns another object, then the returned object
70
+ will be used in subsequent steps.) No conversion; the object itself is used. The
71
+ Default Comparator The default, built-in comparator should be sufficient for
72
+ most use cases. In short, it compares numbers numerically, strings
73
+ alphabetically (and case-insensitively), for objects falls back to using their
74
+ index in the original collection, sorts values of different types by type, and
75
+ puts undefined and null values at the end of the sorted list.
76
+
77
+ More specifically, it follows these steps to determine the relative order of
78
+ items:
79
+
80
+ If the compared values are of different types: If one of the values is
81
+ undefined, consider it "greater than" the other. Else if one of the values is
82
+ null, consider it "greater than" the other. Else compare the types themselves
83
+ alphabetically. If both values are of type string, compare them alphabetically
84
+ in a case- and locale-insensitive way. If both values are objects, compare their
85
+ indices instead. Otherwise, return: 0, if the values are equal (by strict
86
+ equality comparison, i.e., using ===). -1, if the 1st value is "less than" the
87
+ 2nd value (compared using the < operator). 1, otherwise. Note: If you notice
88
+ numbers not being sorted as expected, make sure they are actually being saved as
89
+ numbers and not strings. Note: For the purpose of sorting, null and undefined
90
+ are considered "greater than" any other value (with undefined "greater than"
91
+ null). This effectively means that null and undefined values end up at the end
92
+ of a list sorted in ascending order. Note: null values use 'null' as their type
93
+ to be able to distinguish them from objects.
94
+
95
+ Parameters collection {Array|ArrayLike}: The collection (array or array-like
96
+ object) to sort.
97
+
98
+ expression {(Function|string|Array.<Function|string>)=}: A predicate (or list of
99
+ predicates) to be used by the comparator to determine the order of elements.
100
+
101
+ Can be one of:
102
+
103
+ Function: A getter function. This function will be called with each item as an
104
+ argument and the return value will be used for sorting. string: An AngularTS
105
+ expression. This expression will be evaluated against each item and the result
106
+ will be used for sorting. For example, use 'label' to sort by a property called
107
+ label or 'label.substring(0, 3)' to sort by the first 3 characters of the label
108
+ property. (The result of a constant expression is interpreted as a property name
109
+ to be used for comparison. For example, use '"special name"' (note the extra
110
+ pair of quotes) to sort by a property called special name.) An expression can be
111
+ optionally prefixed with + or - to control the sorting direction, ascending or
112
+ descending. For example, '+label' or '-label'. If no property is provided,
113
+ (e.g., '+' or '-'), the collection element itself is used in comparisons. Array:
114
+ An array of function and/or string predicates. If a predicate cannot determine
115
+ the relative order of two items, the next predicate is used as a tie-breaker.
116
+ Note: If the predicate is missing or empty, then it defaults to '+'.
117
+
118
+ reverse {boolean=}: If true, reverse the sorting order.
119
+
120
+ comparator {(Function)=}: The comparator function used to determine the relative
121
+ order of value pairs. If omitted, the built-in comparator will be used.
122
+
123
+ Returns {Array}: The sorted array.
@@ -0,0 +1,194 @@
1
+ ---
2
+ title: $sceProvider
3
+ description: >
4
+ Strict Contextual Escaping service
5
+ ---
6
+
7
+ # `$sceProvider` and `$sce` Documentation
8
+
9
+ ## `$sceProvider`
10
+
11
+ The `$sceProvider` provider allows developers to configure the [`$sce`](#sce)
12
+ service.
13
+
14
+ - Enable/disable Strict Contextual Escaping (SCE) in a module
15
+ - Override the default implementation with a custom delegate
16
+
17
+ Read more about [Strict Contextual Escaping (SCE)](#strict-contextual-escaping).
18
+
19
+ ---
20
+
21
+ ## `$sce`
22
+
23
+ `$sce` is a service that provides **Strict Contextual Escaping (SCE)** services
24
+ to AngularTS.
25
+
26
+ ---
27
+
28
+ ## Strict Contextual Escaping
29
+
30
+ ### Overview
31
+
32
+ Strict Contextual Escaping (SCE) is a mode in which AngularTS constrains
33
+ bindings to only render trusted values. Its goal is to:
34
+
35
+ - Help you write **secure-by-default** code.
36
+ - Simplify **auditing for vulnerabilities** such as XSS and clickjacking.
37
+
38
+ By default, AngularTS treats **all values as untrusted** in HTML or sensitive
39
+ URL bindings. When binding untrusted values, AngularTS will:
40
+
41
+ - Sanitize or validate them based on context.
42
+ - Or throw an error if it cannot guarantee safety.
43
+
44
+ Example — `ng-bind-html` renders its value directly as HTML (its “context”). If
45
+ the input is untrusted, AngularTS will sanitize or reject it.
46
+
47
+ To bypass sanitization, you must mark a value as trusted before binding it.
48
+
49
+ > **Note:** Since version 1.2, AngularTS ships with SCE **enabled by default**.
50
+
51
+ ---
52
+
53
+ ### Example: Binding in a Privileged Context
54
+
55
+ ```html
56
+ <input ng-model="userHtml" aria-label="User input" />
57
+ <div ng-bind-html="userHtml"></div>
58
+ ```
59
+
60
+ If SCE is disabled, this allows arbitrary HTML injection — a serious XSS risk.
61
+
62
+ To safely render user content, you should sanitize the HTML (on the server or
63
+ client) **before** binding it.
64
+
65
+ SCE ensures that only trusted, validated, or sanitized values are rendered.
66
+
67
+ You can mark trusted values explicitly using:
68
+
69
+ ```js
70
+ $sce.trustAs(context, value);
71
+ ```
72
+
73
+ or shorthand methods such as:
74
+
75
+ ```js
76
+ $sce.trustAsHtml(value);
77
+ $sce.trustAsUrl(value);
78
+ $sce.trustAsResourceUrl(value);
79
+ ```
80
+
81
+ ---
82
+
83
+ ### How It Works
84
+
85
+ Directives and Angular internals bind trusted values using:
86
+
87
+ ```js
88
+ $sce.getTrusted(context, value);
89
+ ```
90
+
91
+ Example: the `ngBindHtml` directive uses `$sce.parseAsHtml` internally:
92
+
93
+ ```js
94
+ let ngBindHtmlDirective = [
95
+ '$sce',
96
+ function ($sce) {
97
+ return function (scope, element, attr) {
98
+ scope.$watch($sce.parseAsHtml(attr.ngBindHtml), function (value) {
99
+ element.html(value || '');
100
+ });
101
+ };
102
+ },
103
+ ];
104
+ ```
105
+
106
+ ---
107
+
108
+ ### Impact on Loading Templates
109
+
110
+ SCE affects both:
111
+
112
+ - The [`ng-include`](https://docs.angularjs.org/api/ng/directive/ngInclude)
113
+ directive
114
+ - The `templateUrl` property in directives
115
+
116
+ By default, AngularTS loads templates **only** from the same domain and protocol
117
+ as the main document.
118
+ It uses:
119
+
120
+ ```js
121
+ $sce.getTrustedResourceUrl(url);
122
+ ```
123
+
124
+ To allow templates from other domains, use:
125
+
126
+ - `$sceDelegateProvider.trustedResourceUrlList`
127
+ - Or `$sce.trustAsResourceUrl(url)`
128
+
129
+ > **Note:** Browser CORS and Same-Origin policies still apply.
130
+
131
+ ---
132
+
133
+ ### Is This Too Much Overhead?
134
+
135
+ SCE applies only to **interpolation expressions**.
136
+
137
+ Constant literals are automatically trusted, e.g.:
138
+
139
+ ```html
140
+ <div ng-bind-html="'<b>implicitly trusted</b>'"></div>
141
+ ```
142
+
143
+ If the `ngSanitize` module is included, `$sceDelegate` will use `$sanitize` to
144
+ clean untrusted HTML automatically.
145
+
146
+ AngularTS’ default `$sceDelegate` allows loading from your app’s domain,
147
+ blocking others unless explicitly whitelisted.
148
+
149
+ This small overhead provides major security benefits and simplifies auditing.
150
+
151
+ ---
152
+
153
+ ### Supported Trusted Contexts
154
+
155
+ | Context | Description |
156
+ | ------------------- | ---------------------------------------------------------- |
157
+ | `$sce.HTML` | Safe HTML (used by `ng-bind-html`). |
158
+ | `$sce.CSS` | Safe CSS. Currently unused. |
159
+ | `$sce.MEDIA_URL` | Safe media URLs (auto-sanitized). |
160
+ | `$sce.URL` | Safe navigable URLs. |
161
+ | `$sce.RESOURCE_URL` | Safe resource URLs (used in `ng-include`, `iframe`, etc.). |
162
+ | `$sce.JS` | Safe JavaScript for execution. |
163
+
164
+ > ⚠️ Before AngularTS 1.7.0, `a[href]` and `img[src]` sanitized directly.
165
+ > As of 1.7.0, these now use `$sce.URL` and `$sce.MEDIA_URL` respectively.
166
+
167
+ ---
168
+
169
+ ### Resource URL List Patterns
170
+
171
+ Trusted and banned resource URL lists accept:
172
+
173
+ - `'self'` → matches same domain & protocol
174
+ - Strings with wildcards:
175
+ - `*` → matches within a single path segment
176
+ - `**` → matches across path segments (use carefully)
177
+ - Regular expressions (`RegExp`)
178
+
179
+ > **Caution:** Regex patterns are powerful but harder to maintain — use only
180
+ > when necessary.
181
+
182
+ ---
183
+
184
+ ### Disabling SCE (Not Recommended)
185
+
186
+ You can disable SCE globally — though this is strongly discouraged.
187
+
188
+ ```js
189
+ angular.module('myAppWithSceDisabled', []).config(function ($sceProvider) {
190
+ // Completely disable SCE. For demonstration purposes only!
191
+ // Do not use in new projects or libraries.
192
+ $sceProvider.enabled(false);
193
+ });
194
+ ```
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $templateRequestProvider
3
+ description: >
4
+ Template request service
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $compile
3
+ description: >
4
+ Template compilation service
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $controller
3
+ description: >
4
+ Controller service
5
+ ---
@@ -0,0 +1,161 @@
1
+ ---
2
+ title: $http
3
+ description: >
4
+ HTTP service
5
+ ---
6
+
7
+ # `$http` Service (AngularTS)
8
+
9
+ The `$http` service is a core AngularTS service that facilitates communication
10
+ with remote HTTP servers via the browser's
11
+ [XMLHttpRequest](https://developer.mozilla.org/en/xmlhttprequest) object or via
12
+ [JSONP](http://en.wikipedia.org/wiki/JSONP).
13
+
14
+ For unit testing applications that use the `$http` service, see
15
+ [`$httpBackend` mock](https://docs.angularjs.org/api/ngMock/service/$httpBackend).
16
+
17
+ For a higher-level abstraction, see the
18
+ [`$resource`](https://docs.angularjs.org/api/ngResource/service/$resource)
19
+ service.
20
+
21
+ The `$http` API is based on the
22
+ [`$q` deferred/promise APIs](https://docs.angularjs.org/api/ng/service/$q).
23
+ Familiarity with these APIs is important for advanced usage.
24
+
25
+ ---
26
+
27
+ ## General Usage
28
+
29
+ The `$http` service is a function that takes a single argument — a
30
+ **configuration object** — used to generate an HTTP request. It returns a
31
+ **promise** that resolves on success or rejects on failure with a **response
32
+ object**.
33
+
34
+ ```js
35
+ $http({
36
+ method: 'GET',
37
+ url: '/someUrl'
38
+ }).then(function successCallback(response) {
39
+ // Called asynchronously when the response is available
40
+ }, function errorCallback(response) {
41
+ // Called asynchronously if an error occurs or the server returns an error
42
+ });
43
+
44
+ Shortcut Methods
45
+
46
+ Shortcut methods are available for all common HTTP methods. All require a URL; POST/PUT requests require data. An optional config object can be passed as the last argument.
47
+
48
+ $http.get('/someUrl', config).then(successCallback, errorCallback);
49
+ $http.post('/someUrl', data, config).then(successCallback, errorCallback);
50
+
51
+
52
+ Shortcut methods list:
53
+
54
+ $http.get
55
+ $http.head
56
+ $http.post
57
+ $http.put
58
+ $http.delete
59
+ $http.patch
60
+
61
+ $http.get(...);
62
+
63
+ Setting HTTP Headers
64
+
65
+ The $http service automatically adds certain HTTP headers to all requests. These defaults can be configured using $httpProvider.defaults.headers.
66
+
67
+ Default headers:
68
+
69
+ Common headers: Accept: application/json, text/plain, */*
70
+
71
+ POST headers: Content-Type: application/json
72
+
73
+ PUT headers: Content-Type: application/json
74
+
75
+ You can modify defaults:
76
+
77
+ $httpProvider.defaults.headers.get = { 'My-Header': 'value' };
78
+
79
+
80
+ Or modify headers globally at runtime:
81
+
82
+ module.run(function($http) {
83
+ $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w';
84
+ });
85
+
86
+
87
+ Per-request overrides:
88
+
89
+ let req = {
90
+ method: 'POST',
91
+ url: 'http://example.com',
92
+ headers: {
93
+ 'Content-Type': undefined
94
+ },
95
+ data: { test: 'test' }
96
+ };
97
+
98
+ $http(req).then(success, error);
99
+
100
+ Transforming Requests and Responses
101
+
102
+ Requests and responses can be transformed using transformRequest and transformResponse. Each can be a single function or an array of functions. Functions take (data, headersGetter[, status]) and return the transformed value.
103
+
104
+ Note: AngularTS does not make a copy of data before passing it to transformRequest. Avoid side effects.
105
+
106
+ Default transformations:
107
+
108
+ Requests: objects are serialized to JSON
109
+
110
+ Responses: XSRF prefix removed; JSON responses are parsed
111
+
112
+ Per-request override example:
113
+
114
+ function appendTransform(defaults, transform) {
115
+ defaults = angular.isArray(defaults) ? defaults : [defaults];
116
+ return defaults.concat(transform);
117
+ }
118
+
119
+ $http({
120
+ url: '...',
121
+ method: 'GET',
122
+ transformResponse: appendTransform($http.defaults.transformResponse, function(value) {
123
+ return doTransform(value);
124
+ })
125
+ });
126
+
127
+ Caching
128
+
129
+ By default, $http responses are not cached. Enable caching with:
130
+
131
+ config.cache = true or a cache object
132
+
133
+ Global default cache: $http.defaults.cache = true
134
+
135
+ Only GET and JSONP requests are cached.
136
+
137
+ Interceptors
138
+
139
+ Interceptors allow modification of requests/responses globally. Add factories to $httpProvider.interceptors.
140
+
141
+ Interceptor types:
142
+
143
+ request(config)
144
+
145
+ requestError(rejection)
146
+
147
+ response(response)
148
+
149
+ responseError(rejection)
150
+
151
+ Example:
152
+
153
+ $provide.factory('myHttpInterceptor', function($q) {
154
+ return {
155
+ request: function(config) { return config; },
156
+ responseError: function(rejection) { return $q.reject(rejection); }
157
+ };
158
+ });
159
+
160
+ $httpProvider.interceptors.push('myHttpInterceptor');
161
+ ```
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $interpolate
3
+ description: >
4
+ HTTP service
5
+ ---
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: $log
3
3
  description: >
4
- A simple service for logging
4
+ Logging service
5
5
  ---
6
6
 
7
7
  ### Using `$log`
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $parse
3
+ description: >
4
+ URL normalization for HTML5/hashbang modes
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $rootElement
3
+ description: >
4
+ URL normalization for HTML5/hashbang modes
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: $rootScope
3
+ description: >
4
+ Root scope service
5
+ ---