@angular/core 6.0.3 → 6.0.7

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 (233) hide show
  1. package/bundles/core-testing.umd.js +61 -237
  2. package/bundles/core-testing.umd.js.map +1 -1
  3. package/bundles/core-testing.umd.min.js +11 -4
  4. package/bundles/core-testing.umd.min.js.map +1 -1
  5. package/bundles/core.umd.js +591 -2007
  6. package/bundles/core.umd.js.map +1 -1
  7. package/bundles/core.umd.min.js +4 -32
  8. package/bundles/core.umd.min.js.map +1 -1
  9. package/core.metadata.json +1 -1
  10. package/esm2015/core.externs.js +3 -3
  11. package/esm2015/src/application_init.js +2 -9
  12. package/esm2015/src/application_module.js +1 -10
  13. package/esm2015/src/application_ref.js +15 -30
  14. package/esm2015/src/change_detection/change_detector_ref.js +7 -5
  15. package/esm2015/src/change_detection/differs/iterable_differs.js +4 -3
  16. package/esm2015/src/change_detection/differs/keyvalue_differs.js +4 -3
  17. package/esm2015/src/change_detection/pipe_transform.js +3 -6
  18. package/esm2015/src/console.js +0 -11
  19. package/esm2015/src/di/forward_ref.js +8 -6
  20. package/esm2015/src/di/injectable.js +1 -4
  21. package/esm2015/src/di/injection_token.js +6 -8
  22. package/esm2015/src/di/injector.js +5 -10
  23. package/esm2015/src/di/metadata.js +1 -16
  24. package/esm2015/src/di/provider.js +47 -138
  25. package/esm2015/src/di/reflective_errors.js +14 -7
  26. package/esm2015/src/di/reflective_injector.js +22 -24
  27. package/esm2015/src/di/reflective_provider.js +11 -12
  28. package/esm2015/src/error_handler.js +2 -5
  29. package/esm2015/src/event_emitter.js +6 -3
  30. package/esm2015/src/i18n/tokens.js +7 -4
  31. package/esm2015/src/linker/compiler.js +1 -12
  32. package/esm2015/src/linker/query_list.js +4 -4
  33. package/esm2015/src/linker/system_js_ng_module_factory_loader.js +3 -10
  34. package/esm2015/src/linker/view_ref.js +10 -7
  35. package/esm2015/src/metadata/di.js +10 -16
  36. package/esm2015/src/metadata/directives.js +111 -33
  37. package/esm2015/src/metadata/lifecycle_hooks.js +9 -9
  38. package/esm2015/src/metadata/ng_module.js +19 -11
  39. package/esm2015/src/render3/node_manipulation.js +2 -3
  40. package/esm2015/src/render3/view_ref.js +7 -3
  41. package/esm2015/src/testability/testability.js +2 -16
  42. package/esm2015/src/version.js +1 -1
  43. package/esm2015/src/view/ng_module.js +4 -1
  44. package/esm2015/src/zone/ng_zone.js +2 -1
  45. package/esm2015/testing/src/fake_async.js +5 -3
  46. package/esm2015/testing/src/fake_async_fallback.js +5 -3
  47. package/esm2015/testing/src/logger.js +0 -7
  48. package/esm2015/testing/src/metadata_override.js +1 -1
  49. package/esm2015/testing/src/ng_zone_mock.js +0 -7
  50. package/esm2015/testing/src/test_bed.js +1 -34
  51. package/esm2015/testing/src/test_compiler.js +1 -12
  52. package/esm5/index.js +5 -1
  53. package/esm5/public_api.js +6 -1
  54. package/esm5/src/application_init.js +3 -5
  55. package/esm5/src/application_module.js +2 -2
  56. package/esm5/src/application_ref.js +35 -211
  57. package/esm5/src/application_tokens.js +1 -1
  58. package/esm5/src/change_detection/change_detection.js +1 -1
  59. package/esm5/src/change_detection/change_detection_util.js +7 -72
  60. package/esm5/src/change_detection/change_detector_ref.js +1 -1
  61. package/esm5/src/change_detection/constants.js +1 -24
  62. package/esm5/src/change_detection/differs/default_iterable_differ.js +26 -209
  63. package/esm5/src/change_detection/differs/default_keyvalue_differ.js +7 -38
  64. package/esm5/src/change_detection/differs/iterable_differs.js +5 -42
  65. package/esm5/src/change_detection/differs/keyvalue_differs.js +6 -51
  66. package/esm5/src/change_detection/pipe_transform.js +1 -1
  67. package/esm5/src/change_detection.js +6 -1
  68. package/esm5/src/codegen_private_exports.js +1 -1
  69. package/esm5/src/console.js +2 -7
  70. package/esm5/src/core.js +6 -1
  71. package/esm5/src/core_private_export.js +1 -1
  72. package/esm5/src/core_render3_private_export.js +2 -1
  73. package/esm5/src/debug/debug_node.js +3 -15
  74. package/esm5/src/di/defs.js +1 -1
  75. package/esm5/src/di/forward_ref.js +7 -6
  76. package/esm5/src/di/injectable.js +2 -3
  77. package/esm5/src/di/injection_token.js +5 -83
  78. package/esm5/src/di/injector.js +13 -27
  79. package/esm5/src/di/metadata.js +1 -6
  80. package/esm5/src/di/provider.js +1 -1
  81. package/esm5/src/di/r3_injector.js +13 -39
  82. package/esm5/src/di/reflective_errors.js +14 -7
  83. package/esm5/src/di/reflective_injector.js +19 -265
  84. package/esm5/src/di/reflective_key.js +4 -45
  85. package/esm5/src/di/reflective_provider.js +17 -35
  86. package/esm5/src/di/scope.js +1 -1
  87. package/esm5/src/di.js +6 -1
  88. package/esm5/src/error_handler.js +7 -66
  89. package/esm5/src/errors.js +1 -1
  90. package/esm5/src/event_emitter.js +4 -95
  91. package/esm5/src/i18n/tokens.js +9 -49
  92. package/esm5/src/linker/compiler.js +9 -69
  93. package/esm5/src/linker/component_factory.js +2 -18
  94. package/esm5/src/linker/component_factory_resolver.js +1 -1
  95. package/esm5/src/linker/element_ref.js +2 -32
  96. package/esm5/src/linker/ng_module_factory.js +3 -25
  97. package/esm5/src/linker/ng_module_factory_loader.js +2 -10
  98. package/esm5/src/linker/query_list.js +12 -112
  99. package/esm5/src/linker/system_js_ng_module_factory_loader.js +4 -16
  100. package/esm5/src/linker/template_ref.js +2 -26
  101. package/esm5/src/linker/view_container_ref.js +2 -38
  102. package/esm5/src/linker/view_ref.js +10 -115
  103. package/esm5/src/linker.js +2 -1
  104. package/esm5/src/metadata/di.js +7 -25
  105. package/esm5/src/metadata/directives.js +111 -20
  106. package/esm5/src/metadata/lifecycle_hooks.js +1 -1
  107. package/esm5/src/metadata/ng_module.js +14 -9
  108. package/esm5/src/metadata/view.js +1 -20
  109. package/esm5/src/metadata.js +1 -1
  110. package/esm5/src/platform_core_providers.js +1 -1
  111. package/esm5/src/profile/profile.js +1 -1
  112. package/esm5/src/profile/wtf_impl.js +1 -1
  113. package/esm5/src/reflection/platform_reflection_capabilities.js +1 -1
  114. package/esm5/src/reflection/reflection.js +1 -1
  115. package/esm5/src/reflection/reflection_capabilities.js +3 -8
  116. package/esm5/src/reflection/reflector.js +2 -10
  117. package/esm5/src/reflection/types.js +1 -1
  118. package/esm5/src/render/api.js +7 -71
  119. package/esm5/src/render.js +2 -1
  120. package/esm5/src/render3/assert.js +1 -1
  121. package/esm5/src/render3/component.js +6 -5
  122. package/esm5/src/render3/definition.js +6 -8
  123. package/esm5/src/render3/di.js +9 -14
  124. package/esm5/src/render3/errors.js +1 -1
  125. package/esm5/src/render3/hooks.js +2 -2
  126. package/esm5/src/render3/index.js +11 -1
  127. package/esm5/src/render3/instructions.js +52 -38
  128. package/esm5/src/render3/interfaces/container.js +1 -1
  129. package/esm5/src/render3/interfaces/definition.js +1 -1
  130. package/esm5/src/render3/interfaces/injector.js +1 -1
  131. package/esm5/src/render3/interfaces/node.js +1 -1
  132. package/esm5/src/render3/interfaces/projection.js +1 -1
  133. package/esm5/src/render3/interfaces/query.js +1 -1
  134. package/esm5/src/render3/interfaces/renderer.js +1 -3
  135. package/esm5/src/render3/interfaces/view.js +1 -1
  136. package/esm5/src/render3/ng_dev_mode.js +1 -1
  137. package/esm5/src/render3/node_assert.js +1 -1
  138. package/esm5/src/render3/node_manipulation.js +12 -15
  139. package/esm5/src/render3/node_selector_matcher.js +2 -2
  140. package/esm5/src/render3/pipe.js +1 -1
  141. package/esm5/src/render3/pure_function.js +1 -1
  142. package/esm5/src/render3/query.js +11 -59
  143. package/esm5/src/render3/util.js +1 -1
  144. package/esm5/src/render3/view_ref.js +15 -345
  145. package/esm5/src/sanitization/html_sanitizer.js +8 -12
  146. package/esm5/src/sanitization/inert_body.js +8 -72
  147. package/esm5/src/sanitization/sanitization.js +1 -1
  148. package/esm5/src/sanitization/security.js +2 -37
  149. package/esm5/src/sanitization/style_sanitizer.js +1 -1
  150. package/esm5/src/sanitization/url_sanitizer.js +1 -1
  151. package/esm5/src/testability/testability.js +21 -143
  152. package/esm5/src/type.js +1 -1
  153. package/esm5/src/util/decorators.js +1 -1
  154. package/esm5/src/util/lang.js +1 -1
  155. package/esm5/src/util/property.js +1 -1
  156. package/esm5/src/util.js +6 -1
  157. package/esm5/src/version.js +3 -13
  158. package/esm5/src/view/element.js +7 -7
  159. package/esm5/src/view/entrypoint.js +1 -1
  160. package/esm5/src/view/errors.js +1 -1
  161. package/esm5/src/view/index.js +1 -1
  162. package/esm5/src/view/ng_content.js +1 -1
  163. package/esm5/src/view/ng_module.js +4 -1
  164. package/esm5/src/view/provider.js +12 -12
  165. package/esm5/src/view/pure_expression.js +1 -1
  166. package/esm5/src/view/query.js +6 -6
  167. package/esm5/src/view/refs.js +8 -14
  168. package/esm5/src/view/services.js +16 -20
  169. package/esm5/src/view/text.js +1 -1
  170. package/esm5/src/view/types.js +19 -41
  171. package/esm5/src/view/util.js +5 -5
  172. package/esm5/src/view/view.js +4 -6
  173. package/esm5/src/view/view_attach.js +5 -5
  174. package/esm5/src/zone/ng_zone.js +22 -257
  175. package/esm5/src/zone.js +2 -1
  176. package/esm5/testing/index.js +5 -1
  177. package/esm5/testing/public_api.js +6 -1
  178. package/esm5/testing/src/async.js +1 -1
  179. package/esm5/testing/src/async_fallback.js +1 -1
  180. package/esm5/testing/src/async_test_completer.js +2 -8
  181. package/esm5/testing/src/before_each.js +6 -1
  182. package/esm5/testing/src/component_fixture.js +9 -75
  183. package/esm5/testing/src/fake_async.js +12 -3
  184. package/esm5/testing/src/fake_async_fallback.js +5 -3
  185. package/esm5/testing/src/lang_utils.js +1 -1
  186. package/esm5/testing/src/logger.js +1 -1
  187. package/esm5/testing/src/metadata_override.js +1 -1
  188. package/esm5/testing/src/ng_zone_mock.js +1 -1
  189. package/esm5/testing/src/private_export_testing.js +1 -1
  190. package/esm5/testing/src/render3.js +1 -5
  191. package/esm5/testing/src/test_bed.js +20 -172
  192. package/esm5/testing/src/test_compiler.js +5 -43
  193. package/esm5/testing/src/testing.js +6 -1
  194. package/esm5/testing/src/testing_internal.js +3 -9
  195. package/fesm2015/core.js +248 -177
  196. package/fesm2015/core.js.map +1 -1
  197. package/fesm2015/testing.js +9 -13
  198. package/fesm2015/testing.js.map +1 -1
  199. package/fesm5/core.js +591 -2007
  200. package/fesm5/core.js.map +1 -1
  201. package/fesm5/testing.js +61 -237
  202. package/fesm5/testing.js.map +1 -1
  203. package/package.json +1 -1
  204. package/src/application_ref.d.ts +7 -8
  205. package/src/change_detection/change_detector_ref.d.ts +6 -4
  206. package/src/change_detection/differs/iterable_differs.d.ts +3 -2
  207. package/src/change_detection/differs/keyvalue_differs.d.ts +3 -2
  208. package/src/change_detection/pipe_transform.d.ts +2 -5
  209. package/src/di/forward_ref.d.ts +7 -5
  210. package/src/di/injectable.d.ts +4 -14
  211. package/src/di/injection_token.d.ts +5 -7
  212. package/src/di/injector.d.ts +7 -10
  213. package/src/di/metadata.d.ts +13 -86
  214. package/src/di/provider.d.ts +55 -150
  215. package/src/di/reflective_errors.d.ts +13 -6
  216. package/src/di/reflective_injector.d.ts +21 -23
  217. package/src/di/reflective_provider.d.ts +7 -8
  218. package/src/error_handler.d.ts +1 -4
  219. package/src/event_emitter.d.ts +3 -0
  220. package/src/i18n/tokens.d.ts +8 -4
  221. package/src/linker/query_list.d.ts +2 -2
  222. package/src/linker/view_ref.d.ts +9 -6
  223. package/src/metadata/di.d.ts +41 -59
  224. package/src/metadata/directives.d.ts +410 -460
  225. package/src/metadata/lifecycle_hooks.d.ts +8 -8
  226. package/src/metadata/ng_module.d.ts +49 -38
  227. package/src/render3/view_ref.d.ts +6 -2
  228. package/src/zone/ng_zone.d.ts +1 -0
  229. package/testing/src/fake_async.d.ts +4 -2
  230. package/testing/src/fake_async_fallback.d.ts +4 -2
  231. package/testing/src/metadata_override.d.ts +3 -3
  232. package/testing.d.ts +0 -5
  233. package/testing.metadata.json +1 -1
@@ -12,25 +12,9 @@ import { TypeDecorator } from '../util/decorators';
12
12
  import { ViewEncapsulation } from './view';
13
13
  /**
14
14
  * Type of the Directive decorator / constructor function.
15
- *
16
- *
17
15
  */
18
16
  export interface DirectiveDecorator {
19
17
  /**
20
- * @usageNotes
21
- *
22
- * ```
23
- * import {Directive} from '@angular/core';
24
- *
25
- * @Directive({
26
- * selector: 'my-directive',
27
- * })
28
- * export class MyDirective {
29
- * }
30
- * ```
31
- *
32
- * @description
33
- *
34
18
  * Marks a class as an Angular directive and collects directive configuration
35
19
  * metadata.
36
20
  *
@@ -61,12 +45,23 @@ export interface DirectiveDecorator {
61
45
  * * **queries** - configure queries that can be injected into the component
62
46
  * * **selector** - css selector that identifies this component in a template
63
47
  *
48
+ * @usageNotes
49
+ *
50
+ * ```
51
+ * import {Directive} from '@angular/core';
52
+ *
53
+ * @Directive({
54
+ * selector: 'my-directive',
55
+ * })
56
+ * export class MyDirective {
57
+ * }
58
+ * ```
64
59
  *
65
60
  * @Annotation
66
61
  */
67
62
  (obj: Directive): TypeDecorator;
68
63
  /**
69
- * See the {@link Directive} decorator.
64
+ * See the `Directive` decorator.
70
65
  */
71
66
  new (obj: Directive): Directive;
72
67
  }
@@ -86,7 +81,7 @@ export interface Directive {
86
81
  * - `:not(sub_selector)`: select only if the element does not match the `sub_selector`.
87
82
  * - `selector1, selector2`: select if either `selector1` or `selector2` matches.
88
83
  *
89
- *
84
+ * @usageNotes
90
85
  * ### Example
91
86
  *
92
87
  * Suppose we have a directive with an `input[type=text]` selector.
@@ -117,7 +112,8 @@ export interface Directive {
117
112
  *
118
113
  * When `bindingProperty` is not provided, it is assumed to be equal to `directiveProperty`.
119
114
  *
120
- * ### Example ([live demo](http://plnkr.co/edit/ivhfXY?p=preview))
115
+ * @usageNotes
116
+ * ### Example
121
117
  *
122
118
  * The following example creates a component with two data-bound properties.
123
119
  *
@@ -134,19 +130,7 @@ export interface Directive {
134
130
  * bankName: string;
135
131
  * id: string;
136
132
  *
137
- * // this property is not bound, and won't be automatically updated by Angular
138
- * normalizedBankName: string;
139
- * }
140
- *
141
- * @Component({
142
- * selector: 'app',
143
- * template: `
144
- * <bank-account bankName="RBC" account-id="4747"></bank-account>
145
- * `
146
- * })
147
- * class App {}
148
133
  * ```
149
- *
150
134
  */
151
135
  inputs?: string[];
152
136
  /**
@@ -161,42 +145,34 @@ export interface Directive {
161
145
  * - `directiveProperty` specifies the component property that emits events.
162
146
  * - `bindingProperty` specifies the DOM property the event handler is attached to.
163
147
  *
164
- * ### Example ([live demo](http://plnkr.co/edit/d5CNq7?p=preview))
148
+ * @usageNotes
149
+ * ### Example
165
150
  *
166
151
  * ```typescript
167
152
  * @Directive({
168
- * selector: 'interval-dir',
169
- * outputs: ['everySecond', 'five5Secs: everyFiveSeconds']
153
+ * selector: 'child-dir',
154
+ * exportAs: 'child'
170
155
  * })
171
- * class IntervalDir {
172
- * everySecond = new EventEmitter();
173
- * five5Secs = new EventEmitter();
174
- *
175
- * constructor() {
176
- * setInterval(() => this.everySecond.emit("event"), 1000);
177
- * setInterval(() => this.five5Secs.emit("event"), 5000);
178
- * }
156
+ * class ChildDir {
179
157
  * }
180
158
  *
181
159
  * @Component({
182
- * selector: 'app',
183
- * template: `
184
- * <interval-dir (everySecond)="everySecond()" (everyFiveSeconds)="everyFiveSeconds()">
185
- * </interval-dir>
186
- * `
160
+ * selector: 'main',
161
+ * template: `<child-dir #c="child"></child-dir>`
187
162
  * })
188
- * class App {
189
- * everySecond() { console.log('second'); }
190
- * everyFiveSeconds() { console.log('five seconds'); }
163
+ * class MainComponent {
191
164
  * }
192
165
  * ```
193
- *
194
166
  */
195
167
  outputs?: string[];
196
168
  /**
197
169
  * Specify the events, actions, properties and attributes related to the host element.
198
170
  *
199
- * ## Host Listeners
171
+ * @usageNotes
172
+ * The key corresponds to the name of the event, property or attribute on the host to
173
+ * bind. The value is formatted differently depending upon the type of the binding.
174
+ *
175
+ * ### Host Listeners
200
176
  *
201
177
  * Specifies which DOM events a directive listens to via a set of `(event)` to `method`
202
178
  * key-value pairs:
@@ -211,8 +187,6 @@ export interface Directive {
211
187
  *
212
188
  * When writing a directive event binding, you can also refer to the $event local variable.
213
189
  *
214
- * ### Example ([live demo](http://plnkr.co/edit/DlA5KU?p=preview))
215
- *
216
190
  * The following example declares a directive that attaches a click listener to the button and
217
191
  * counts clicks.
218
192
  *
@@ -237,16 +211,15 @@ export interface Directive {
237
211
  * })
238
212
  * class App {}
239
213
  * ```
214
+ * See [live demo](http://plnkr.co/edit/DlA5KU?p=preview)
240
215
  *
241
- * ## Host Property Bindings
216
+ * ### Host Property Bindings
242
217
  *
243
218
  * Specifies which DOM properties a directive updates.
244
219
  *
245
220
  * Angular automatically checks host property bindings during change detection.
246
221
  * If a binding changes, it will update the host element of the directive.
247
222
  *
248
- * ### Example ([live demo](http://plnkr.co/edit/gNg0ED?p=preview))
249
- *
250
223
  * The following example creates a directive that sets the `valid` and `invalid` classes
251
224
  * on the DOM element that has ngModel directive on it.
252
225
  *
@@ -272,13 +245,12 @@ export interface Directive {
272
245
  * prop;
273
246
  * }
274
247
  * ```
248
+ * See [live demo](http://plnkr.co/edit/gNg0ED?p=preview).
275
249
  *
276
- * ## Attributes
250
+ * ### Attributes
277
251
  *
278
252
  * Specifies static attributes that should be propagated to a host element.
279
253
  *
280
- * ### Example
281
- *
282
254
  * In this example using `my-button` directive (ex.: `<div my-button></div>`) on a host element
283
255
  * (here: `<div>` ) will ensure that this element will get the "button" role.
284
256
  *
@@ -292,17 +264,18 @@ export interface Directive {
292
264
  * class MyButton {
293
265
  * }
294
266
  * ```
295
- */
296
- host?: {
297
- [key: string]: string;
298
- };
299
- /**
300
- * Defines the set of injectable objects that are visible to a Directive and its light DOM
301
- * children.
267
+ * Attaching the `my-button` directive to the host `<div>` element
268
+ * ensures that this element gets the "button" role.
269
+ *
270
+ * ```html
271
+ * <div my-button></div>
272
+ * ```
302
273
  *
303
- * ## Simple Example
274
+ * @usageNotes
275
+ * ### Simple Example
304
276
  *
305
- * Here is an example of a class that can be injected:
277
+ * The following simple example shows how a class is injected,
278
+ * using a provider specified in the directive metadata:
306
279
  *
307
280
  * ```
308
281
  * class Greeter {
@@ -330,7 +303,8 @@ export interface Directive {
330
303
  /**
331
304
  * Defines the name that can be used in the template to assign this directive to a variable.
332
305
  *
333
- * ## Simple Example
306
+ * @usageNotes
307
+ * ### Simple Example
334
308
  *
335
309
  * ```
336
310
  * @Directive({
@@ -356,8 +330,10 @@ export interface Directive {
356
330
  * Content queries are set before the `ngAfterContentInit` callback is called.
357
331
  * View queries are set before the `ngAfterViewInit` callback is called.
358
332
  *
333
+ * @usageNotes
359
334
  * ### Example
360
335
  *
336
+ * The followoing example (shows what??)
361
337
  * ```
362
338
  * @Component({
363
339
  * selector: 'someDir',
@@ -380,6 +356,8 @@ export interface Directive {
380
356
  * }
381
357
  * }
382
358
  * ```
359
+ *
360
+ * @Annotation
383
361
  */
384
362
  queries?: {
385
363
  [key: string]: any;
@@ -388,100 +366,145 @@ export interface Directive {
388
366
  /**
389
367
  * Directive decorator and metadata.
390
368
  *
391
- *
392
369
  * @Annotation
393
370
  */
394
- export declare const Directive: DirectiveDecorator;
395
- /**
396
- * Type of the Component decorator / constructor function.
397
- *
398
- *
399
- */
400
- export interface ComponentDecorator {
371
+ export interface Directive {
401
372
  /**
402
- * @usageNotes
373
+ * The CSS selector that identifies this directive in a template
374
+ * and triggers instantiation of the directive.
403
375
  *
404
- * {@example core/ts/metadata/metadata.ts region='component'}
376
+ * Declare as one of the following:
405
377
  *
406
- * @description
407
- * Marks a class as an Angular component and collects component configuration
408
- * metadata.
378
+ * - `element-name`: Select by element name.
379
+ * - `.class`: Select by class name.
380
+ * - `[attribute]`: Select by attribute name.
381
+ * - `[attribute=value]`: Select by attribute name and value.
382
+ * - `:not(sub_selector)`: Select only if the element does not match the `sub_selector`.
383
+ * - `selector1, selector2`: Select if either `selector1` or `selector2` matches.
409
384
  *
410
- * Component decorator allows you to mark a class as an Angular component and provide additional
411
- * metadata that determines how the component should be processed, instantiated and used at
412
- * runtime.
385
+ * Angular only allows directives to apply on CSS selectors that do not cross
386
+ * element boundaries.
413
387
  *
414
- * Components are the most basic building block of an UI in an Angular application.
415
- * An Angular application is a tree of Angular components.
416
- * Angular components are a subset of directives. Unlike directives, components always have
417
- * a template and only one component can be instantiated per an element in a template.
388
+ * For the following template HTML, a directive with an `input[type=text]` selector,
389
+ * would be instantiated only on the `<input type="text">` element.
418
390
  *
419
- * A component must belong to an NgModule in order for it to be usable
420
- * by another component or application. To specify that a component is a member of an NgModule,
421
- * you should list it in the `declarations` field of that NgModule.
391
+ * ```html
392
+ * <form>
393
+ * <input type="text">
394
+ * <input type="radio">
395
+ * <form>
396
+ * ```
422
397
  *
423
- * In addition to the metadata configuration specified via the Component decorator,
424
- * components can control their runtime behavior by implementing various Life-Cycle hooks.
398
+ */
399
+ selector?: string;
400
+ /**
401
+ * The set of event-bound output properties.
402
+ * When an output property emits an event, an event handler attached
403
+ * to that event in the template is invoked.
425
404
  *
426
- * **Metadata Properties:**
405
+ * Each output property maps a `directiveProperty` to a `bindingProperty`:
406
+ * - `directiveProperty` specifies the component property that emits events.
407
+ * - `bindingProperty` specifies the HTML attribute the event handler is attached to.
427
408
  *
428
- * * **animations** - list of animations of this component
429
- * * **changeDetection** - change detection strategy used by this component
430
- * * **encapsulation** - style encapsulation strategy used by this component
431
- * * **entryComponents** - list of components that are dynamically inserted into the view of this
432
- * component
433
- * * **exportAs** - name under which the component instance is exported in a template
434
- * * **host** - map of class property to host element bindings for events, properties and
435
- * attributes
436
- * * **inputs** - list of class property names to data-bind as component inputs
437
- * * **interpolation** - custom interpolation markers used in this component's template
438
- * * **moduleId** - ES/CommonJS module id of the file in which this component is defined
439
- * * **outputs** - list of class property names that expose output events that others can
440
- * subscribe to
441
- * * **providers** - list of providers available to this component and its children
442
- * * **queries** - configure queries that can be injected into the component
443
- * * **selector** - css selector that identifies this component in a template
444
- * * **styleUrls** - list of urls to stylesheets to be applied to this component's view
445
- * * **styles** - inline-defined styles to be applied to this component's view
446
- * * **template** - inline-defined template for the view
447
- * * **templateUrl** - url to an external file containing a template for the view
448
- * * **viewProviders** - list of providers available to this component and its view children
409
+ */
410
+ outputs?: string[];
411
+ /**
412
+ * Maps class properties to host element bindings for properties,
413
+ * attributes, and events, using a set of key-value pairs.
449
414
  *
450
- * ### Example
415
+ * Angular automatically checks host property bindings during change detection.
416
+ * If a binding changes, Angular updates the directive's host element.
451
417
  *
452
- * {@example core/ts/metadata/metadata.ts region='component'}
418
+ * When the key is a property of the host element, the property value is
419
+ * the propagated to the specified DOM property.
453
420
  *
421
+ * When the key is a static attribute in the DOM, the attribute value
422
+ * is propagated to the specified property in the host element.
423
+ *
424
+ * For event handling:
425
+ * - The key is the DOM event that the directive listens to.
426
+ * To listen to global events, add the target to the event name.
427
+ * The target can be `window`, `document` or `body`.
428
+ * - The value is the statement to execute when the event occurs. If the
429
+ * statement evalueates to `false`, then `preventDefault` is applied on the DOM
430
+ * event. A handler method can refer to the `$event` local variable.
454
431
  *
455
- * @Annotation
456
432
  */
457
- (obj: Component): TypeDecorator;
433
+ host?: {
434
+ [key: string]: string;
435
+ };
458
436
  /**
459
- * See the {@link Component} decorator.
437
+ * See the `Component` decorator.
460
438
  */
461
- new (obj: Component): Component;
439
+ providers?: Provider[];
440
+ /**
441
+ * The name or names that can be used in the template to assign this directive to a variable.
442
+ * For multiple names, use a comma-separated string.
443
+ *
444
+ */
445
+ exportAs?: string;
446
+ /**
447
+ * Configures the queries that will be injected into the directive.
448
+ *
449
+ * Content queries are set before the `ngAfterContentInit` callback is called.
450
+ * View queries are set before the `ngAfterViewInit` callback is called.
451
+ *
452
+ */
453
+ queries?: {
454
+ [key: string]: any;
455
+ };
462
456
  }
463
457
  /**
464
458
  * Type of the Component metadata.
465
- *
459
+ */
460
+ export declare const Directive: DirectiveDecorator;
461
+ /**
462
+ * Component decorator interface
466
463
  *
467
464
  */
468
- export interface Component extends Directive {
465
+ export interface ComponentDecorator {
469
466
  /**
470
- * Defines the used change detection strategy.
467
+ * Decorator that marks a class as an Angular component and provides configuration
468
+ * metadata that determines how the component should be processed,
469
+ * instantiated, and used at runtime.
471
470
  *
472
- * When a component is instantiated, Angular creates a change detector, which is responsible for
473
- * propagating the component's bindings.
471
+ * Components are the most basic UI building block of an Angular app.
472
+ * An Angular app contains a tree of Angular components.
474
473
  *
475
- * The `changeDetection` property defines, whether the change detection will be checked every time
476
- * or only when the component tells it to do so.
477
- */
478
- changeDetection?: ChangeDetectionStrategy;
479
- /**
480
- * Defines the set of injectable objects that are visible to its view DOM children.
474
+ * Angular components are a subset of directives, always associated with a template.
475
+ * Unlike other directives, only one component can be instantiated per an element in a template.
476
+ *
477
+ * A component must belong to an NgModule in order for it to be available
478
+ * to another component or application. To make it a member of an NgModule,
479
+ * list it in the `declarations` field of the `@NgModule` metadata.
480
+ *
481
+ * Note that, in addition to these options for configuring a directive,
482
+ * you can control a component's runtime behavior by implementing
483
+ * life-cycle hooks. For more information, see the
484
+ * [Lifecycle Hooks](guide/lifecycle-hooks) guide.
485
+ *
486
+ * @usageNotes
481
487
  *
482
- * ## Simple Example
488
+ * ### Setting component inputs
483
489
  *
484
- * Here is an example of a class that can be injected:
490
+ * The following example creates a component with two data-bound properties,
491
+ * specified by the `inputs` value.
492
+ *
493
+ * <code-example path="core/ts/metadata/directives.ts" region="component-input">
494
+ * </code-example>
495
+ *
496
+ *
497
+ * ### Setting component outputs
498
+ *
499
+ * The following example shows two event emitters that emit on an interval. One
500
+ * emits an output every second, while the other emits every five seconds.
501
+ *
502
+ * {@example core/ts/metadata/directives.ts region='component-output-interval'}
503
+ *
504
+ * ### Injecting a class with a view provider
505
+ *
506
+ * The following simple example injects a class into a component
507
+ * using the view provider specified in component metadata:
485
508
  *
486
509
  * ```
487
510
  * class Greeter {
@@ -512,312 +535,300 @@ export interface Component extends Directive {
512
535
  * }
513
536
  *
514
537
  * ```
538
+ *
539
+ *
540
+ * @Annotation
515
541
  */
516
- viewProviders?: Provider[];
542
+ (obj: Component): TypeDecorator;
517
543
  /**
518
- * The module id of the module that contains the component.
519
- * Needed to be able to resolve relative urls for templates and styles.
520
- * In CommonJS, this can always be set to `module.id`, similarly SystemJS exposes `__moduleName`
521
- * variable within each module.
522
- *
544
+ * See the `@Component` decorator.
545
+ */
546
+ new (obj: Component): Component;
547
+ }
548
+ /**
549
+ * Supplies configuration metadata for an Angular component.
550
+ */
551
+ export interface Component extends Directive {
552
+ /**
553
+ * The change-detection strategy to use for this component.
523
554
  *
524
- * ## Simple Example
555
+ * When a component is instantiated, Angular creates a change detector,
556
+ * which is responsible for propagating the component's bindings.
557
+ * The strategy is one of:
558
+ * - `ChangeDetectionStrategy#OnPush` sets the strategy to `CheckOnce` (on demand).
559
+ * - `ChangeDetectionStrategy#Default` sets the strategy to `CheckAlways`.
560
+ */
561
+ changeDetection?: ChangeDetectionStrategy;
562
+ /**
563
+ * Defines the set of injectable objects that are visible to its view DOM children.
564
+ * See [example](#injecting-a-class-with-a-view-provider).
525
565
  *
526
- * ```
527
- * @Directive({
528
- * selector: 'someDir',
529
- * moduleId: module.id
530
- * })
531
- * class SomeDir {
532
- * }
566
+ */
567
+ viewProviders?: Provider[];
568
+ /**
569
+ * The module ID of the module that contains the component.
570
+ * The component must be able to resolve relative URLs for templates and styles.
571
+ * SystemJS exposes the `__moduleName` variable within each module.
572
+ * In CommonJS, this can be set to `module.id`.
533
573
  *
534
- * ```
535
574
  */
536
575
  moduleId?: string;
537
576
  /**
538
- * Specifies a template URL for an Angular component.
577
+ * The URL of a template file for an Angular component. If provided,
578
+ * do not supply an inline template using `template`.
539
579
  *
540
- *Only one of `templateUrl` or `template` can be defined per View.
541
580
  */
542
581
  templateUrl?: string;
543
582
  /**
544
- * Specifies an inline template for an Angular component.
583
+ * An inline template for an Angular component. If provided,
584
+ * do not supply a template file using `templateUrl`.
545
585
  *
546
- * Only one of `templateUrl` or `template` can be defined per Component.
547
586
  */
548
587
  template?: string;
549
588
  /**
550
- * Specifies stylesheet URLs for an Angular component.
589
+ * One or more URLs for files containing CSS stylesheets to use
590
+ * in this component.
551
591
  */
552
592
  styleUrls?: string[];
553
593
  /**
554
- * Specifies inline stylesheets for an Angular component.
594
+ * One or more inline CSS stylesheets to use
595
+ * in this component.
555
596
  */
556
597
  styles?: string[];
557
598
  /**
558
- * Animations are defined on components via an animation-like DSL. This DSL approach to describing
559
- * animations allows for a flexibility that both benefits developers and the framework.
560
- *
561
- * Animations work by listening on state changes that occur on an element within
562
- * the template. When a state change occurs, Angular can then take advantage and animate the
563
- * arc in between. This works similar to how CSS transitions work, however, by having a
564
- * programmatic DSL, animations are not limited to environments that are DOM-specific.
565
- * (Angular can also perform optimizations behind the scenes to make animations more performant.)
566
- *
567
- * For animations to be available for use, animation state changes are placed within
568
- * {@link trigger animation triggers} which are housed inside of the `animations` annotation
569
- * metadata. Within a trigger both {@link state state} and {@link transition transition} entries
570
- * can be placed.
571
- *
572
- * ```typescript
573
- * @Component({
574
- * selector: 'animation-cmp',
575
- * templateUrl: 'animation-cmp.html',
576
- * animations: [
577
- * // this here is our animation trigger that
578
- * // will contain our state change animations.
579
- * trigger('myTriggerName', [
580
- * // the styles defined for the `on` and `off`
581
- * // states declared below are persisted on the
582
- * // element once the animation completes.
583
- * state('on', style({ opacity: 1 }),
584
- * state('off', style({ opacity: 0 }),
585
- *
586
- * // this here is our animation that kicks off when
587
- * // this state change jump is true
588
- * transition('on => off', [
589
- * animate("1s")
590
- * ])
591
- * ])
592
- * ]
593
- * })
594
- * ```
595
- *
596
- * As depicted in the code above, a group of related animation states are all contained within
597
- * an animation `trigger` (the code example above called the trigger `myTriggerName`).
598
- * When a trigger is created then it can be bound onto an element within the component's
599
- * template via a property prefixed by an `@` symbol followed by trigger name and an expression
600
- * that
601
- * is used to determine the state value for that trigger.
602
- *
603
- * ```html
604
- * <!-- animation-cmp.html -->
605
- * <div @myTriggerName="expression">...</div>
606
- * ```
599
+ * One or more animation `trigger()` calls, containing
600
+ * `state()` and `transition()` definitions.
601
+ * See the [Animations guide](/guide/animations) and animations API documentation.
607
602
  *
608
- * For state changes to be executed, the `expression` value must change value from its existing
609
- * value
610
- * to something that we have set an animation to animate on (in the example above we are listening
611
- * to a change of state between `on` and `off`). The `expression` value attached to the trigger
612
- * must be something that can be evaluated with the template/component context.
613
- *
614
- * ### DSL Animation Functions
615
- *
616
- * Please visit each of the animation DSL functions listed below to gain a better understanding
617
- * of how and why they are used for crafting animations in Angular:
618
- *
619
- * - {@link trigger trigger()}
620
- * - {@link state state()}
621
- * - {@link transition transition()}
622
- * - {@link group group()}
623
- * - {@link sequence sequence()}
624
- * - {@link style style()}
625
- * - {@link animate animate()}
626
- * - {@link keyframes keyframes()}
627
603
  */
628
604
  animations?: any[];
629
605
  /**
630
- * Specifies how the template and the styles should be encapsulated:
631
- * - {@link ViewEncapsulation#Native `ViewEncapsulation.Native`} to use shadow roots - only works
632
- * if natively available on the platform,
633
- * - {@link ViewEncapsulation#Emulated `ViewEncapsulation.Emulated`} to use shimmed CSS that
634
- * emulates the native behavior,
635
- * - {@link ViewEncapsulation#None `ViewEncapsulation.None`} to use global CSS without any
636
- * encapsulation.
637
- *
638
- * When no `encapsulation` is defined for the component, the default value from the
639
- * {@link CompilerOptions} is used. The default is `ViewEncapsulation.Emulated`}. Provide a new
640
- * `CompilerOptions` to override this value.
641
- *
642
- * If the encapsulation is set to `ViewEncapsulation.Emulated` and the component has no `styles`
643
- * nor `styleUrls` the encapsulation will automatically be switched to `ViewEncapsulation.None`.
606
+ * An encapsulation policy for the template and CSS styles. One of:
607
+ * - `ViewEncapsulation.Native`: Use shadow roots. This works
608
+ * only if natively available on the platform.
609
+ * - `ViewEncapsulation.Emulated`: Use shimmed CSS that
610
+ * emulates the native behavior.
611
+ * - `ViewEncapsulation.None`: Use global CSS without any
612
+ * encapsulation.
613
+ *
614
+ * If not supplied, the value is taken from `CompilerOptions`. The default compiler option is
615
+ * `ViewEncapsulation.Emulated`.
616
+ *
617
+ * If the policy is set to `ViewEncapsulation.Emulated` and the component has no `styles`
618
+ * or `styleUrls` specified, the policy is automatically switched to `ViewEncapsulation.None`.
644
619
  */
645
620
  encapsulation?: ViewEncapsulation;
646
621
  /**
647
- * Overrides the default encapsulation start and end delimiters (respectively `{{` and `}}`)
622
+ * Overrides the default encapsulation start and end delimiters (`{{` and `}}`)
648
623
  */
649
624
  interpolation?: [string, string];
650
625
  /**
651
- * Defines the components that should be compiled as well when
652
- * this component is defined. For each components listed here,
653
- * Angular will create a {@link ComponentFactory} and store it in the
626
+ * A set of components that should be compiled along with
627
+ * this component. For each component listed here,
628
+ * Angular creates a {@link ComponentFactory} and stores it in the
654
629
  * {@link ComponentFactoryResolver}.
655
630
  */
656
631
  entryComponents?: Array<Type<any> | any[]>;
657
632
  /**
658
- * If {@link Component#preserveWhitespaces Component.preserveWhitespaces} is set to `false`
659
- * potentially superfluous whitespace characters (ones matching the `\s` character class in
660
- * JavaScript regular expressions) will be removed from a compiled template. This can greatly
661
- * reduce AOT-generated code size as well as speed up view creation.
662
- *
663
- * Current implementation works according to the following rules:
664
- * - all whitespaces at the beginning and the end of a template are removed (trimmed);
665
- * - text nodes consisting of whitespaces only are removed (ex.:
666
- * `<button>Action 1</button> <button>Action 2</button>` will be converted to
667
- * `<button>Action 1</button><button>Action 2</button>` (no whitespaces between buttons);
668
- * - series of whitespaces in text nodes are replaced with one space (ex.:
669
- * `<span>\n some text\n</span>` will be converted to `<span> some text </span>`);
670
- * - text nodes are left as-is inside HTML tags where whitespaces are significant (ex. `<pre>`,
671
- * `<textarea>`).
672
- *
673
- * Described transformations may (potentially) influence DOM nodes layout. However, the impact
674
- * should so be minimal. That's why starting from Angular 6, the
675
- * `preserveWhitespaces` option is `false` by default (whitespace removal).
676
- * If you want to change the default setting for all components in your application you can use
677
- * the `preserveWhitespaces` option of the AOT compiler.
678
- *
679
- * Even with the default behavior of whitespace removal, there are ways of preserving whitespaces
680
- * in certain fragments of a template. You can either exclude entire DOM sub-tree by using the
681
- * `ngPreserveWhitespaces` attribute, ex.:
682
- *
683
- * ```html
684
- * <div ngPreserveWhitespaces>
685
- * whitespaces are preserved here
686
- * <span> and here </span>
687
- * </div>
688
- * ```
689
- *
690
- * Alternatively you can force a space to be preserved in a text node by using the `&ngsp;`
691
- * pseudo-entity. `&ngsp;` will be replaced with a space character by Angular's template
692
- * compiler, ex.:
693
- *
694
- * ```html
695
- * <a>Spaces</a>&ngsp;<a>between</a>&ngsp;<a>links.</a>
696
- * ```
697
- *
698
- * will be compiled to the equivalent of:
699
- *
700
- * ```html
701
- * <a>Spaces</a> <a>between</a> <a>links.</a>
702
- * ```
703
- *
704
- * Please note that sequences of `&ngsp;` are still collapsed to just one space character when
705
- * the `preserveWhitespaces` option is set to `false`. Ex.:
706
- *
707
- * ```html
708
- * <a>before</a>&ngsp;&ngsp;&ngsp;<a>after</a>
709
- * ```
710
- *
711
- * would be equivalent to:
712
- *
713
- * ```html
714
- * <a>before</a> <a>after</a>
715
- * ```
716
- *
717
- * The `&ngsp;` pseudo-entity is useful for forcing presence of
718
- * one space (a text node having `&ngsp;` pseudo-entities will never be removed), but it is not
719
- * meant to mark sequences of whitespace characters. The previously described
720
- * `ngPreserveWhitespaces` attribute is more useful for preserving sequences of whitespace
721
- * characters.
633
+ * True to preserve or false to remove potentially superfluous whitespace characters
634
+ * from the compiled template. Whitespace characters are those matching the `\s`
635
+ * character class in JavaScript regular expressions. Default is false, unless
636
+ * overridden in compiler options.
722
637
  */
723
638
  preserveWhitespaces?: boolean;
724
639
  }
725
640
  /**
726
641
  * Component decorator and metadata.
727
642
  *
643
+ * @usageNotes
644
+ *
645
+ * ### Using animations
646
+ *
647
+ * The following snippet shows an animation trigger in a component's
648
+ * metadata. The trigger is attached to an element in the component's
649
+ * template, using "@_trigger_name_", and a state expression that is evaluated
650
+ * at run time to determine whether the animation should start.
651
+ *
652
+ * ```typescript
653
+ * @Component({
654
+ * selector: 'animation-cmp',
655
+ * templateUrl: 'animation-cmp.html',
656
+ * animations: [
657
+ * trigger('myTriggerName', [
658
+ * state('on', style({ opacity: 1 }),
659
+ * state('off', style({ opacity: 0 }),
660
+ * transition('on => off', [
661
+ * animate("1s")
662
+ * ])
663
+ * ])
664
+ * ]
665
+ * })
666
+ * ```
667
+ *
668
+ * ```html
669
+ * <!-- animation-cmp.html -->
670
+ * <div @myTriggerName="expression">...</div>
671
+ * ```
672
+ *
673
+ * ### Preserving whitespace
674
+ *
675
+ * Removing whitespace can greatly reduce AOT-generated code size, and speed up view creation.
676
+ * As of Angular 6, default for `preserveWhitespaces` is false (whitespace is removed).
677
+ * To change the default setting for all components in your application, set
678
+ * the `preserveWhitespaces` option of the AOT compiler.
679
+ *
680
+ * Current implementation removes whitespace characters as follows:
681
+ * - Trims all whitespaces at the beginning and the end of a template.
682
+ * - Removes whitespace-only text nodes. For example,
683
+ * `<button>Action 1</button> <button>Action 2</button>` becomes
684
+ * `<button>Action 1</button><button>Action 2</button>`.
685
+ * - Replaces a series of whitespace characters in text nodes with a single space.
686
+ * For example, `<span>\n some text\n</span>` becomes `<span> some text </span>`.
687
+ * - Does NOT alter text nodes inside HTML tags such as `<pre>` or `<textarea>`,
688
+ * where whitespace characters are significant.
689
+ *
690
+ * Note that these transformations can influence DOM nodes layout, although impact
691
+ * should be minimal.
692
+ *
693
+ * You can override the default behavior to preserve whitespace characters
694
+ * in certain fragments of a template. For example, you can exclude an entire
695
+ * DOM sub-tree by using the `ngPreserveWhitespaces` attribute:
696
+ *
697
+ * ```html
698
+ * <div ngPreserveWhitespaces>
699
+ * whitespaces are preserved here
700
+ * <span> and here </span>
701
+ * </div>
702
+ * ```
703
+ *
704
+ * You can force a single space to be preserved in a text node by using `&ngsp;`,
705
+ * which is replaced with a space character by Angular's template
706
+ * compiler:
707
+ *
708
+ * ```html
709
+ * <a>Spaces</a>&ngsp;<a>between</a>&ngsp;<a>links.</a>
710
+ * <!-->compiled to be equivalent to:</>
711
+ * <a>Spaces</a> <a>between</a> <a>links.</a>
712
+ * ```
713
+ *
714
+ * Note that sequences of `&ngsp;` are still collapsed to just one space character when
715
+ * the `preserveWhitespaces` option is set to `false`.
716
+ *
717
+ * ```html
718
+ * <a>before</a>&ngsp;&ngsp;&ngsp;<a>after</a>
719
+ * <!-->compiled to be equivalent to:</>
720
+ * <a>Spaces</a> <a>between</a> <a>links.</a>
721
+ * ```
722
+ *
723
+ * To preserve sequences of whitespace characters, use the
724
+ * `ngPreserveWhitespaces` attribute.
728
725
  *
729
726
  * @Annotation
730
727
  */
731
728
  export declare const Component: ComponentDecorator;
732
729
  /**
733
730
  * Type of the Pipe decorator / constructor function.
734
- *
735
- *
736
731
  */
737
732
  export interface PipeDecorator {
738
733
  /**
739
- * Declare reusable pipe function.
740
- *
741
- * A "pure" pipe is only re-evaluated when either the input or any of the arguments change.
734
+ * Declares a reusable pipe function, and supplies configuration metadata.
742
735
  *
743
- * When not specified, pipes default to being pure.
744
736
  */
745
737
  (obj: Pipe): TypeDecorator;
746
738
  /**
747
- * See the {@link Pipe} decorator.
739
+ * See the `Pipe` decorator.
748
740
  */
749
741
  new (obj: Pipe): Pipe;
750
742
  }
751
743
  /**
752
744
  * Type of the Pipe metadata.
753
- *
754
- *
755
745
  */
756
746
  export interface Pipe {
757
747
  /**
758
- * Name of the pipe.
748
+ * The pipe name to use in template bindings.
759
749
  *
760
- * The pipe name is used in template bindings. For example if a pipe is named
761
- * `myPipe` then it would be used in the template binding expression like
762
- * so: `{{ exp | myPipe }}`.
763
750
  */
764
751
  name: string;
765
752
  /**
766
- * If Pipe is pure (its output depends only on its input.)
753
+ * When true, the pipe is pure, meaning that the
754
+ * `transform()` method is invoked only when its input arguments
755
+ * change. Pipes are pure by default.
767
756
  *
768
- * Normally pipe's `transform` method is only invoked when the inputs to pipe`s
769
- * `transform` method change. If the pipe has internal state (it's result are
770
- * dependent on state other than its arguments) than set `pure` to `false` so
771
- * that the pipe is invoked on each change-detection even if the arguments to the
772
- * pipe do not change.
757
+ * If the pipe has internal state (that is, the result
758
+ * depends on state other than its arguments), set `pure` to false.
759
+ * In this case, the pipe is invoked on each change-detection cycle,
760
+ * even if the arguments have not changed.
773
761
  */
774
762
  pure?: boolean;
775
763
  }
776
764
  /**
777
- * Pipe decorator and metadata.
778
- *
779
- * Use the `@Pipe` annotation to declare that a given class is a pipe. A pipe
780
- * class must also implement {@link PipeTransform} interface.
781
- *
782
- * To use the pipe include a reference to the pipe class in
783
- * {@link NgModule#declarations}.
784
765
  *
785
766
  *
786
767
  * @Annotation
787
768
  */
788
769
  export declare const Pipe: PipeDecorator;
789
770
  /**
790
- * Type of the Input decorator / constructor function.
791
- *
792
771
  *
793
772
  */
794
773
  export interface InputDecorator {
795
774
  /**
796
- * Declares a data-bound input property.
775
+ * Decorator that marks a class as pipe and supplies configuration metadata.
797
776
  *
798
- * Angular automatically updates data-bound properties during change detection.
777
+ * A pipe class must implement the `PipeTransform` interface.
778
+ * For example, if the name is "myPipe", use a template binding expression
779
+ * such as the following:
799
780
  *
800
- * `Input` takes an optional parameter that specifies the name
801
- * used when instantiating a component in the template. When not provided,
802
- * the name of the decorated property is used.
781
+ * ```
782
+ * {{ exp | myPipe }}
783
+ * ```
803
784
  *
804
- * ### Example
785
+ * The result of the expression is passed to the pipe's `transform()` method.
805
786
  *
806
- * The following example creates a component with two input properties.
787
+ * A pipe must belong to an NgModule in order for it to be available
788
+ * to a template. To make it a member of an NgModule,
789
+ * list it in the `declarations` field of the `@NgModule` metadata.
790
+ *
791
+ */
792
+ (bindingPropertyName?: string): any;
793
+ new (bindingPropertyName?: string): any;
794
+ }
795
+ /**
796
+ * Type of metadata for an `Input` property.
797
+ *
798
+ *
799
+ */
800
+ export interface Input {
801
+ /**
802
+ * Decorator that marks a class field as an input property and supplies configuration metadata.
803
+ * Declares a data-bound input property, which Angular automatically updates
804
+ * during change detection.
805
+ *
806
+ * @usageNotes
807
+ *
808
+ * You can supply an optional name to use in templates when the
809
+ * component is instantiated, that maps to the
810
+ * name of the bound property. By default, the original
811
+ * name of the bound property is used for input binding.
812
+ *
813
+ * The following example creates a component with two input properties,
814
+ * one of which is given a special binding name.
807
815
  *
808
816
  * ```typescript
809
817
  * @Component({
810
818
  * selector: 'bank-account',
811
819
  * template: `
812
820
  * Bank Name: {{bankName}}
813
- * Account Id: {{id}}
821
+ * Account Id: {{id}}
814
822
  * `
815
823
  * })
816
824
  * class BankAccount {
825
+ * // This property is bound using its original name.
817
826
  * @Input() bankName: string;
827
+ * // this property value is bound to a different property name
828
+ * // when this component is instantiated in a template.
818
829
  * @Input('account-id') id: string;
819
830
  *
820
- * // this property is not bound, and won't be automatically updated by Angular
831
+ * // this property is not bound, and is not automatically updated by Angular
821
832
  * normalizedBankName: string;
822
833
  * }
823
834
  *
@@ -830,118 +841,66 @@ export interface InputDecorator {
830
841
  *
831
842
  * class App {}
832
843
  * ```
833
- *
834
- */
835
- (bindingPropertyName?: string): any;
836
- new (bindingPropertyName?: string): any;
837
- }
838
- /**
839
- * Type of the Input metadata.
840
- *
841
- *
842
- */
843
- export interface Input {
844
- /**
845
- * Name used when instantiating a component in the template.
846
844
  */
847
845
  bindingPropertyName?: string;
848
846
  }
849
847
  /**
850
- * Input decorator and metadata.
851
- *
852
848
  *
853
849
  * @Annotation
854
850
  */
855
851
  export declare const Input: InputDecorator;
856
852
  /**
857
853
  * Type of the Output decorator / constructor function.
858
- *
859
- *
860
854
  */
861
855
  export interface OutputDecorator {
862
856
  /**
863
- * Declares an event-bound output property.
864
- *
865
- * When an output property emits an event, an event handler attached to that event
866
- * the template is invoked.
867
- *
868
- * `Output` takes an optional parameter that specifies the name
869
- * used when instantiating a component in the template. When not provided,
870
- * the name of the decorated property is used.
871
- *
872
- * ### Example
873
- *
874
- * ```typescript
875
- * @Directive({
876
- * selector: 'interval-dir',
877
- * })
878
- * class IntervalDir {
879
- * @Output() everySecond = new EventEmitter();
880
- * @Output('everyFiveSeconds') five5Secs = new EventEmitter();
881
- *
882
- * constructor() {
883
- * setInterval(() => this.everySecond.emit("event"), 1000);
884
- * setInterval(() => this.five5Secs.emit("event"), 5000);
885
- * }
886
- * }
887
- *
888
- * @Component({
889
- * selector: 'app',
890
- * template: `
891
- * <interval-dir (everySecond)="everySecond()" (everyFiveSeconds)="everyFiveSeconds()">
892
- * </interval-dir>
893
- * `
894
- * })
895
- * class App {
896
- * everySecond() { console.log('second'); }
897
- * everyFiveSeconds() { console.log('five seconds'); }
898
- * }
899
- * ```
900
- *
901
- */
857
+ * Decorator that marks a class field as an output property and supplies configuration metadata.
858
+ * Declares a data-bound output property, which Angular automatically updates
859
+ * during change detection.
860
+ *
861
+ * @usageNotes
862
+ *
863
+ * You can supply an optional name to use in templates when the
864
+ * component is instantiated, that maps to the
865
+ * name of the bound property. By default, the original
866
+ * name of the bound property is used for output binding.
867
+ *
868
+ * See `@Input` decorator for an example of providing a binding name.
869
+ *
870
+ */
902
871
  (bindingPropertyName?: string): any;
903
872
  new (bindingPropertyName?: string): any;
904
873
  }
905
874
  /**
906
875
  * Type of the Output metadata.
907
- *
908
- *
909
876
  */
910
877
  export interface Output {
911
878
  bindingPropertyName?: string;
912
879
  }
913
880
  /**
914
- * Output decorator and metadata.
915
- *
916
881
  *
917
882
  * @Annotation
918
883
  */
919
884
  export declare const Output: OutputDecorator;
920
885
  /**
921
886
  * Type of the HostBinding decorator / constructor function.
922
- *
923
- *
924
887
  */
925
888
  export interface HostBindingDecorator {
926
889
  /**
927
- * Declares a host property binding.
928
- *
929
- * Angular automatically checks host property bindings during change detection.
930
- * If a binding changes, it will update the host element of the directive.
931
- *
932
- * `HostBinding` takes an optional parameter that specifies the property
933
- * name of the host element that will be updated. When not provided,
934
- * the class property name is used.
890
+ * Decorator that marks a DOM property as a host-binding property and supplies configuration
891
+ * metadata.
892
+ * Angular automatically checks host property bindings during change detection, and
893
+ * if a binding changes it updates the host element of the directive.
935
894
  *
936
- * ### Example
895
+ * @usageNotes
937
896
  *
938
- * The following example creates a directive that sets the `valid` and `invalid` classes
939
- * on the DOM element that has ngModel directive on it.
897
+ * The following example creates a directive that sets the `valid` and `invalid`
898
+ * properties on the DOM element that has an `ngModel` directive on it.
940
899
  *
941
900
  * ```typescript
942
901
  * @Directive({selector: '[ngModel]'})
943
902
  * class NgModelStatus {
944
- * constructor(public control:NgModel) {}
903
+ * constructor(public control: NgModel) {}
945
904
  * @HostBinding('class.valid') get valid() { return this.control.valid; }
946
905
  * @HostBinding('class.invalid') get invalid() { return this.control.invalid; }
947
906
  * }
@@ -954,7 +913,6 @@ export interface HostBindingDecorator {
954
913
  * prop;
955
914
  * }
956
915
  * ```
957
- *
958
916
  */
959
917
  (hostPropertyName?: string): any;
960
918
  new (hostPropertyName?: string): any;
@@ -962,71 +920,63 @@ export interface HostBindingDecorator {
962
920
  /**
963
921
  * Type of the HostBinding metadata.
964
922
  *
965
- *
966
923
  */
967
924
  export interface HostBinding {
968
925
  hostPropertyName?: string;
969
926
  }
970
927
  /**
971
- * HostBinding decorator and metadata.
972
- *
973
928
  *
974
929
  * @Annotation
975
930
  */
976
931
  export declare const HostBinding: HostBindingDecorator;
977
932
  /**
978
933
  * Type of the HostListener decorator / constructor function.
979
- *
980
- *
981
934
  */
982
935
  export interface HostListenerDecorator {
983
- /**
984
- * Declares a host listener.
985
- *
986
- * Angular will invoke the decorated method when the host element emits the specified event.
987
- *
988
- * If the decorated method returns `false`, then `preventDefault` is applied on the DOM event.
989
- *
990
- * ### Example
991
- *
992
- * The following example declares a directive that attaches a click listener to the button and
993
- * counts clicks.
994
- *
995
- * ```typescript
996
- * @Directive({selector: 'button[counting]'})
997
- * class CountClicks {
998
- * numberOfClicks = 0;
999
- *
1000
- * @HostListener('click', ['$event.target'])
1001
- * onClick(btn) {
1002
- * console.log('button', btn, 'number of clicks:', this.numberOfClicks++);
1003
- * }
1004
- * }
1005
- *
1006
- * @Component({
1007
- * selector: 'app',
1008
- * template: '<button counting>Increment</button>',
1009
- * })
1010
- * class App {}
1011
- * ```
1012
- *
1013
- * @Annotation
1014
- */
1015
936
  (eventName: string, args?: string[]): any;
1016
937
  new (eventName: string, args?: string[]): any;
1017
938
  }
1018
939
  /**
1019
940
  * Type of the HostListener metadata.
1020
- *
1021
- *
1022
941
  */
1023
942
  export interface HostListener {
943
+ /**
944
+ * The CSS event to listen for.
945
+ */
1024
946
  eventName?: string;
947
+ /**
948
+ * A set of arguments to pass to the handler method when the event occurs.
949
+ */
1025
950
  args?: string[];
1026
951
  }
1027
952
  /**
1028
- * HostListener decorator and metadata.
1029
- *
953
+ * Binds a CSS event to a host listener and supplies configuration metadata.
954
+ * Angular invokes the supplied handler method when the host element emits the specified event,
955
+ * and updates the bound element with the result.
956
+ * If the handler method returns false, applies `preventDefault` on the bound element.
957
+ *
958
+ * @usageNotes
959
+ *
960
+ * The following example declares a directive
961
+ * that attaches a click listener to a button and counts clicks.
962
+ *
963
+ * ```
964
+ * @Directive({selector: 'button[counting]'})
965
+ * class CountClicks {
966
+ * numberOfClicks = 0;
967
+ *
968
+ * @HostListener('click', ['$event.target'])
969
+ * onClick(btn) {
970
+ * console.log('button', btn, 'number of clicks:', this.numberOfClicks++);
971
+ * }
972
+ * }
973
+ *
974
+ * @Component({
975
+ * selector: 'app',
976
+ * template: '<button counting>Increment</button>',
977
+ * })
978
+ * class App {}
979
+ * ```
1030
980
  *
1031
981
  * @Annotation
1032
982
  */