@angular/core 6.0.6 → 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.
@@ -130,17 +130,6 @@ export interface Directive {
130
130
  * bankName: string;
131
131
  * id: string;
132
132
  *
133
- * // this property is not bound, and won't be automatically updated by Angular
134
- * normalizedBankName: string;
135
- * }
136
- *
137
- * @Component({
138
- * selector: 'app',
139
- * template: `
140
- * <bank-account bankName="RBC" account-id="4747"></bank-account>
141
- * `
142
- * })
143
- * class App {}
144
133
  * ```
145
134
  */
146
135
  inputs?: string[];
@@ -161,29 +150,17 @@ export interface Directive {
161
150
  *
162
151
  * ```typescript
163
152
  * @Directive({
164
- * selector: 'interval-dir',
165
- * outputs: ['everySecond', 'five5Secs: everyFiveSeconds']
153
+ * selector: 'child-dir',
154
+ * exportAs: 'child'
166
155
  * })
167
- * class IntervalDir {
168
- * everySecond = new EventEmitter();
169
- * five5Secs = new EventEmitter();
170
- *
171
- * constructor() {
172
- * setInterval(() => this.everySecond.emit("event"), 1000);
173
- * setInterval(() => this.five5Secs.emit("event"), 5000);
174
- * }
156
+ * class ChildDir {
175
157
  * }
176
158
  *
177
159
  * @Component({
178
- * selector: 'app',
179
- * template: `
180
- * <interval-dir (everySecond)="everySecond()" (everyFiveSeconds)="everyFiveSeconds()">
181
- * </interval-dir>
182
- * `
160
+ * selector: 'main',
161
+ * template: `<child-dir #c="child"></child-dir>`
183
162
  * })
184
- * class App {
185
- * everySecond() { console.log('second'); }
186
- * everyFiveSeconds() { console.log('five seconds'); }
163
+ * class MainComponent {
187
164
  * }
188
165
  * ```
189
166
  */
@@ -234,6 +211,7 @@ export interface Directive {
234
211
  * })
235
212
  * class App {}
236
213
  * ```
214
+ * See [live demo](http://plnkr.co/edit/DlA5KU?p=preview)
237
215
  *
238
216
  * ### Host Property Bindings
239
217
  *
@@ -267,6 +245,7 @@ export interface Directive {
267
245
  * prop;
268
246
  * }
269
247
  * ```
248
+ * See [live demo](http://plnkr.co/edit/gNg0ED?p=preview).
270
249
  *
271
250
  * ### Attributes
272
251
  *
@@ -285,18 +264,18 @@ export interface Directive {
285
264
  * class MyButton {
286
265
  * }
287
266
  * ```
288
- */
289
- host?: {
290
- [key: string]: string;
291
- };
292
- /**
293
- * Defines the set of injectable objects that are visible to a Directive and its light DOM
294
- * 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
+ * ```
295
273
  *
296
274
  * @usageNotes
297
275
  * ### Simple Example
298
276
  *
299
- * 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:
300
279
  *
301
280
  * ```
302
281
  * class Greeter {
@@ -354,6 +333,7 @@ export interface Directive {
354
333
  * @usageNotes
355
334
  * ### Example
356
335
  *
336
+ * The followoing example (shows what??)
357
337
  * ```
358
338
  * @Component({
359
339
  * selector: 'someDir',
@@ -376,6 +356,8 @@ export interface Directive {
376
356
  * }
377
357
  * }
378
358
  * ```
359
+ *
360
+ * @Annotation
379
361
  */
380
362
  queries?: {
381
363
  [key: string]: any;
@@ -386,89 +368,143 @@ export interface Directive {
386
368
  *
387
369
  * @Annotation
388
370
  */
389
- export declare const Directive: DirectiveDecorator;
390
- /**
391
- * Type of the Component decorator / constructor function.
392
- */
393
- export interface ComponentDecorator {
371
+ export interface Directive {
394
372
  /**
395
- * Marks a class as an Angular component and collects component configuration
396
- * metadata.
373
+ * The CSS selector that identifies this directive in a template
374
+ * and triggers instantiation of the directive.
397
375
  *
398
- * Component decorator allows you to mark a class as an Angular component and provide additional
399
- * metadata that determines how the component should be processed, instantiated and used at
400
- * runtime.
376
+ * Declare as one of the following:
401
377
  *
402
- * Components are the most basic building block of an UI in an Angular application.
403
- * An Angular application is a tree of Angular components.
404
- * Angular components are a subset of directives. Unlike directives, components always have
405
- * a template and only one component can be instantiated per an element in a template.
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.
406
384
  *
407
- * A component must belong to an NgModule in order for it to be usable
408
- * by another component or application. To specify that a component is a member of an NgModule,
409
- * you should list it in the `declarations` field of that NgModule.
385
+ * Angular only allows directives to apply on CSS selectors that do not cross
386
+ * element boundaries.
410
387
  *
411
- * In addition to the metadata configuration specified via the Component decorator,
412
- * components can control their runtime behavior by implementing various Life-Cycle hooks.
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.
413
390
  *
414
- * **Metadata Properties:**
391
+ * ```html
392
+ * <form>
393
+ * <input type="text">
394
+ * <input type="radio">
395
+ * <form>
396
+ * ```
415
397
  *
416
- * * **animations** - list of animations of this component
417
- * * **changeDetection** - change detection strategy used by this component
418
- * * **encapsulation** - style encapsulation strategy used by this component
419
- * * **entryComponents** - list of components that are dynamically inserted into the view of this
420
- * component
421
- * * **exportAs** - name under which the component instance is exported in a template
422
- * * **host** - map of class property to host element bindings for events, properties and
423
- * attributes
424
- * * **inputs** - list of class property names to data-bind as component inputs
425
- * * **interpolation** - custom interpolation markers used in this component's template
426
- * * **moduleId** - ES/CommonJS module id of the file in which this component is defined
427
- * * **outputs** - list of class property names that expose output events that others can
428
- * subscribe to
429
- * * **providers** - list of providers available to this component and its children
430
- * * **queries** - configure queries that can be injected into the component
431
- * * **selector** - css selector that identifies this component in a template
432
- * * **styleUrls** - list of urls to stylesheets to be applied to this component's view
433
- * * **styles** - inline-defined styles to be applied to this component's view
434
- * * **template** - inline-defined template for the view
435
- * * **templateUrl** - url to an external file containing a template for the view
436
- * * **viewProviders** - list of providers available to this component and its view children
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.
437
404
  *
438
- * @usageNotes
439
- * ### Example
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.
440
408
  *
441
- * {@example core/ts/metadata/metadata.ts region='component'}
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.
414
+ *
415
+ * Angular automatically checks host property bindings during change detection.
416
+ * If a binding changes, Angular updates the directive's host element.
417
+ *
418
+ * When the key is a property of the host element, the property value is
419
+ * the propagated to the specified DOM property.
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.
442
431
  *
443
- * @Annotation
444
432
  */
445
- (obj: Component): TypeDecorator;
433
+ host?: {
434
+ [key: string]: string;
435
+ };
446
436
  /**
447
437
  * See the `Component` decorator.
448
438
  */
449
- 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
+ };
450
456
  }
451
457
  /**
452
458
  * Type of the Component metadata.
453
459
  */
454
- export interface Component extends Directive {
460
+ export declare const Directive: DirectiveDecorator;
461
+ /**
462
+ * Component decorator interface
463
+ *
464
+ */
465
+ export interface ComponentDecorator {
455
466
  /**
456
- * 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.
457
470
  *
458
- * When a component is instantiated, Angular creates a change detector, which is responsible for
459
- * 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.
460
473
  *
461
- * The `changeDetection` property defines, whether the change detection will be checked every time
462
- * or only when the component tells it to do so.
463
- */
464
- changeDetection?: ChangeDetectionStrategy;
465
- /**
466
- * 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.
467
485
  *
468
486
  * @usageNotes
469
- * ### Simple Example
470
487
  *
471
- * Here is an example of a class that can be injected:
488
+ * ### Setting component inputs
489
+ *
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:
472
508
  *
473
509
  * ```
474
510
  * class Greeter {
@@ -499,220 +535,194 @@ export interface Component extends Directive {
499
535
  * }
500
536
  *
501
537
  * ```
538
+ *
539
+ *
540
+ * @Annotation
502
541
  */
503
- viewProviders?: Provider[];
542
+ (obj: Component): TypeDecorator;
543
+ /**
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 {
504
552
  /**
505
- * The module id of the module that contains the component.
506
- * Needed to be able to resolve relative urls for templates and styles.
507
- * In CommonJS, this can always be set to `module.id`, similarly SystemJS exposes `__moduleName`
508
- * variable within each module.
553
+ * The change-detection strategy to use for this component.
509
554
  *
510
- * @usageNotes
511
- * ### 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).
512
565
  *
513
- * ```
514
- * @Directive({
515
- * selector: 'someDir',
516
- * moduleId: module.id
517
- * })
518
- * class SomeDir {
519
- * }
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`.
520
573
  *
521
- * ```
522
574
  */
523
575
  moduleId?: string;
524
576
  /**
525
- * 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`.
526
579
  *
527
- * Only one of `templateUrl` or `template` can be defined per View.
528
580
  */
529
581
  templateUrl?: string;
530
582
  /**
531
- * 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`.
532
585
  *
533
- * Only one of `templateUrl` or `template` can be defined per Component.
534
586
  */
535
587
  template?: string;
536
588
  /**
537
- * Specifies stylesheet URLs for an Angular component.
589
+ * One or more URLs for files containing CSS stylesheets to use
590
+ * in this component.
538
591
  */
539
592
  styleUrls?: string[];
540
593
  /**
541
- * Specifies inline stylesheets for an Angular component.
594
+ * One or more inline CSS stylesheets to use
595
+ * in this component.
542
596
  */
543
597
  styles?: string[];
544
598
  /**
545
- * Animations are defined on components via an animation-like DSL. This DSL approach to describing
546
- * animations allows for a flexibility that both benefits developers and the framework.
547
- *
548
- * Animations work by listening on state changes that occur on an element within
549
- * the template. When a state change occurs, Angular can then take advantage and animate the
550
- * arc in between. This works similar to how CSS transitions work, however, by having a
551
- * programmatic DSL, animations are not limited to environments that are DOM-specific.
552
- * (Angular can also perform optimizations behind the scenes to make animations more performant.)
553
- *
554
- * For animations to be available for use, animation state changes are placed within
555
- * {@link trigger animation triggers} which are housed inside of the `animations` annotation
556
- * metadata. Within a trigger both `state` and `transition` entries
557
- * can be placed.
558
- *
559
- * @usageNotes
560
- * ### Example
561
- *
562
- * ```typescript
563
- * @Component({
564
- * selector: 'animation-cmp',
565
- * templateUrl: 'animation-cmp.html',
566
- * animations: [
567
- * // this here is our animation trigger that
568
- * // will contain our state change animations.
569
- * trigger('myTriggerName', [
570
- * // the styles defined for the `on` and `off`
571
- * // states declared below are persisted on the
572
- * // element once the animation completes.
573
- * state('on', style({ opacity: 1 }),
574
- * state('off', style({ opacity: 0 }),
575
- *
576
- * // this here is our animation that kicks off when
577
- * // this state change jump is true
578
- * transition('on => off', [
579
- * animate("1s")
580
- * ])
581
- * ])
582
- * ]
583
- * })
584
- * ```
585
- *
586
- * As depicted in the code above, a group of related animation states are all contained within
587
- * an animation `trigger` (the code example above called the trigger `myTriggerName`).
588
- * When a trigger is created then it can be bound onto an element within the component's
589
- * template via a property prefixed by an `@` symbol followed by trigger name and an expression
590
- * that
591
- * is used to determine the state value for that trigger.
592
- *
593
- * ```html
594
- * <!-- animation-cmp.html -->
595
- * <div @myTriggerName="expression">...</div>
596
- * ```
597
- *
598
- * For state changes to be executed, the `expression` value must change value from its existing
599
- * value
600
- * to something that we have set an animation to animate on (in the example above we are listening
601
- * to a change of state between `on` and `off`). The `expression` value attached to the trigger
602
- * must be something that can be evaluated with the template/component context.
603
- *
604
- * ### DSL Animation Functions
605
- *
606
- * Please visit each of the animation DSL functions listed below to gain a better understanding
607
- * of how and why they are used for crafting animations in Angular:
599
+ * One or more animation `trigger()` calls, containing
600
+ * `state()` and `transition()` definitions.
601
+ * See the [Animations guide](/guide/animations) and animations API documentation.
608
602
  *
609
- * - `trigger()`
610
- * - `state()`
611
- * - `transition()`
612
- * - `group()`
613
- * - `sequence()`
614
- * - `style()`
615
- * - `animate()`
616
- * - `keyframes()`
617
603
  */
618
604
  animations?: any[];
619
605
  /**
620
- * Specifies how the template and the styles should be encapsulated:
621
- * - `ViewEncapsulation.Native` to use shadow roots - only works if natively available on the
622
- * platform,
623
- * - `ViewEncapsulation.Emulated` to use shimmed CSS that emulates the native behavior,
624
- * - `ViewEncapsulation.None` to use global CSS without any encapsulation.
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.
625
613
  *
626
- * When no `encapsulation` is defined for the component, the default value from the
627
- * `CompilerOptions` is used. The default is `ViewEncapsulation.Emulated`. Provide a new
628
- * `CompilerOptions` to override this value.
614
+ * If not supplied, the value is taken from `CompilerOptions`. The default compiler option is
615
+ * `ViewEncapsulation.Emulated`.
629
616
  *
630
- * If the encapsulation is set to `ViewEncapsulation.Emulated` and the component has no `styles`
631
- * nor `styleUrls` the encapsulation will automatically be switched to `ViewEncapsulation.None`.
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`.
632
619
  */
633
620
  encapsulation?: ViewEncapsulation;
634
621
  /**
635
- * Overrides the default encapsulation start and end delimiters (respectively `{{` and `}}`)
622
+ * Overrides the default encapsulation start and end delimiters (`{{` and `}}`)
636
623
  */
637
624
  interpolation?: [string, string];
638
625
  /**
639
- * Defines the components that should be compiled as well when
640
- * this component is defined. For each components listed here,
641
- * Angular will create a `ComponentFactory` and store it in the
642
- * `ComponentFactoryResolver`.
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
629
+ * {@link ComponentFactoryResolver}.
643
630
  */
644
631
  entryComponents?: Array<Type<any> | any[]>;
645
632
  /**
646
- * If `Component.preserveWhitespaces` is set to `false`
647
- * potentially superfluous whitespace characters (ones matching the `\s` character class in
648
- * JavaScript regular expressions) will be removed from a compiled template. This can greatly
649
- * reduce AOT-generated code size as well as speed up view creation.
650
- *
651
- * Current implementation works according to the following rules:
652
- * - all whitespaces at the beginning and the end of a template are removed (trimmed);
653
- * - text nodes consisting of whitespaces only are removed (ex.:
654
- * `<button>Action 1</button> <button>Action 2</button>` will be converted to
655
- * `<button>Action 1</button><button>Action 2</button>` (no whitespaces between buttons);
656
- * - series of whitespaces in text nodes are replaced with one space (ex.:
657
- * `<span>\n some text\n</span>` will be converted to `<span> some text </span>`);
658
- * - text nodes are left as-is inside HTML tags where whitespaces are significant (ex. `<pre>`,
659
- * `<textarea>`).
660
- *
661
- * Described transformations may (potentially) influence DOM nodes layout. However, the impact
662
- * should so be minimal. That's why starting from Angular 6, the
663
- * `preserveWhitespaces` option is `false` by default (whitespace removal).
664
- * If you want to change the default setting for all components in your application you can use
665
- * the `preserveWhitespaces` option of the AOT compiler.
666
- *
667
- * Even with the default behavior of whitespace removal, there are ways of preserving whitespaces
668
- * in certain fragments of a template. You can either exclude entire DOM sub-tree by using the
669
- * `ngPreserveWhitespaces` attribute, ex.:
670
- *
671
- * ```html
672
- * <div ngPreserveWhitespaces>
673
- * whitespaces are preserved here
674
- * <span> and here </span>
675
- * </div>
676
- * ```
677
- *
678
- * Alternatively you can force a space to be preserved in a text node by using the `&ngsp;`
679
- * pseudo-entity. `&ngsp;` will be replaced with a space character by Angular's template
680
- * compiler, ex.:
681
- *
682
- * ```html
683
- * <a>Spaces</a>&ngsp;<a>between</a>&ngsp;<a>links.</a>
684
- * ```
685
- *
686
- * will be compiled to the equivalent of:
687
- *
688
- * ```html
689
- * <a>Spaces</a> <a>between</a> <a>links.</a>
690
- * ```
691
- *
692
- * Please note that sequences of `&ngsp;` are still collapsed to just one space character when
693
- * the `preserveWhitespaces` option is set to `false`. Ex.:
694
- *
695
- * ```html
696
- * <a>before</a>&ngsp;&ngsp;&ngsp;<a>after</a>
697
- * ```
698
- *
699
- * would be equivalent to:
700
- *
701
- * ```html
702
- * <a>before</a> <a>after</a>
703
- * ```
704
- *
705
- * The `&ngsp;` pseudo-entity is useful for forcing presence of
706
- * one space (a text node having `&ngsp;` pseudo-entities will never be removed), but it is not
707
- * meant to mark sequences of whitespace characters. The previously described
708
- * `ngPreserveWhitespaces` attribute is more useful for preserving sequences of whitespace
709
- * 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.
710
637
  */
711
638
  preserveWhitespaces?: boolean;
712
639
  }
713
640
  /**
714
641
  * Component decorator and metadata.
715
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.
725
+ *
716
726
  * @Annotation
717
727
  */
718
728
  export declare const Component: ComponentDecorator;
@@ -721,11 +731,8 @@ export declare const Component: ComponentDecorator;
721
731
  */
722
732
  export interface PipeDecorator {
723
733
  /**
724
- * Declare reusable pipe function.
734
+ * Declares a reusable pipe function, and supplies configuration metadata.
725
735
  *
726
- * A "pure" pipe is only re-evaluated when either the input or any of the arguments change.
727
- *
728
- * When not specified, pipes default to being pure.
729
736
  */
730
737
  (obj: Pipe): TypeDecorator;
731
738
  /**
@@ -738,68 +745,90 @@ export interface PipeDecorator {
738
745
  */
739
746
  export interface Pipe {
740
747
  /**
741
- * Name of the pipe.
748
+ * The pipe name to use in template bindings.
742
749
  *
743
- * The pipe name is used in template bindings. For example if a pipe is named
744
- * `myPipe` then it would be used in the template binding expression like
745
- * so: `{{ exp | myPipe }}`.
746
750
  */
747
751
  name: string;
748
752
  /**
749
- * 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.
750
756
  *
751
- * Normally pipe's `transform` method is only invoked when the inputs to pipe`s
752
- * `transform` method change. If the pipe has internal state (it's result are
753
- * dependent on state other than its arguments) than set `pure` to `false` so
754
- * that the pipe is invoked on each change-detection even if the arguments to the
755
- * 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.
756
761
  */
757
762
  pure?: boolean;
758
763
  }
759
764
  /**
760
- * Pipe decorator and metadata.
761
- *
762
- * Use the `@Pipe` annotation to declare that a given class is a pipe. A pipe
763
- * class must also implement `PipeTransform` interface.
764
765
  *
765
- * To use the pipe include a reference to the pipe class in
766
- * `NgModule.declarations`.
767
766
  *
768
767
  * @Annotation
769
768
  */
770
769
  export declare const Pipe: PipeDecorator;
771
770
  /**
772
- * Type of the Input decorator / constructor function.
773
- *
774
771
  *
775
772
  */
776
773
  export interface InputDecorator {
777
774
  /**
778
- * Declares a data-bound input property.
775
+ * Decorator that marks a class as pipe and supplies configuration metadata.
779
776
  *
780
- * 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:
781
780
  *
782
- * `Input` takes an optional parameter that specifies the name
783
- * used when instantiating a component in the template. When not provided,
784
- * the name of the decorated property is used.
781
+ * ```
782
+ * {{ exp | myPipe }}
783
+ * ```
785
784
  *
786
- * ### Example
785
+ * The result of the expression is passed to the pipe's `transform()` method.
786
+ *
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.
787
805
  *
788
- * The following example creates a component with two input properties.
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.
789
815
  *
790
816
  * ```typescript
791
817
  * @Component({
792
818
  * selector: 'bank-account',
793
819
  * template: `
794
820
  * Bank Name: {{bankName}}
795
- * Account Id: {{id}}
821
+ * Account Id: {{id}}
796
822
  * `
797
823
  * })
798
824
  * class BankAccount {
825
+ * // This property is bound using its original name.
799
826
  * @Input() bankName: string;
827
+ * // this property value is bound to a different property name
828
+ * // when this component is instantiated in a template.
800
829
  * @Input('account-id') id: string;
801
830
  *
802
- * // 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
803
832
  * normalizedBankName: string;
804
833
  * }
805
834
  *
@@ -813,20 +842,9 @@ export interface InputDecorator {
813
842
  * class App {}
814
843
  * ```
815
844
  */
816
- (bindingPropertyName?: string): any;
817
- new (bindingPropertyName?: string): any;
818
- }
819
- /**
820
- * Type of the Input metadata.
821
- */
822
- export interface Input {
823
- /**
824
- * Name used when instantiating a component in the template.
825
- */
826
845
  bindingPropertyName?: string;
827
846
  }
828
847
  /**
829
- * Input decorator and metadata.
830
848
  *
831
849
  * @Annotation
832
850
  */
@@ -836,46 +854,20 @@ export declare const Input: InputDecorator;
836
854
  */
837
855
  export interface OutputDecorator {
838
856
  /**
839
- * Declares an event-bound output property.
840
- *
841
- * When an output property emits an event, an event handler attached to that event
842
- * the template is invoked.
843
- *
844
- * `Output` takes an optional parameter that specifies the name
845
- * used when instantiating a component in the template. When not provided,
846
- * the name of the decorated property is used.
847
- *
848
- * @usageNotes
849
- * ### Example
850
- *
851
- * ```typescript
852
- * @Directive({
853
- * selector: 'interval-dir',
854
- * })
855
- * class IntervalDir {
856
- * @Output() everySecond = new EventEmitter();
857
- * @Output('everyFiveSeconds') five5Secs = new EventEmitter();
858
- *
859
- * constructor() {
860
- * setInterval(() => this.everySecond.emit("event"), 1000);
861
- * setInterval(() => this.five5Secs.emit("event"), 5000);
862
- * }
863
- * }
864
- *
865
- * @Component({
866
- * selector: 'app',
867
- * template: `
868
- * <interval-dir (everySecond)="everySecond()" (everyFiveSeconds)="everyFiveSeconds()">
869
- * </interval-dir>
870
- * `
871
- * })
872
- * class App {
873
- * everySecond() { console.log('second'); }
874
- * everyFiveSeconds() { console.log('five seconds'); }
875
- * }
876
- * ```
877
- *
878
- */
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
+ */
879
871
  (bindingPropertyName?: string): any;
880
872
  new (bindingPropertyName?: string): any;
881
873
  }
@@ -886,7 +878,6 @@ export interface Output {
886
878
  bindingPropertyName?: string;
887
879
  }
888
880
  /**
889
- * Output decorator and metadata.
890
881
  *
891
882
  * @Annotation
892
883
  */
@@ -896,25 +887,20 @@ export declare const Output: OutputDecorator;
896
887
  */
897
888
  export interface HostBindingDecorator {
898
889
  /**
899
- * Declares a host property binding.
900
- *
901
- * Angular automatically checks host property bindings during change detection.
902
- * If a binding changes, it will update the host element of the directive.
903
- *
904
- * `HostBinding` takes an optional parameter that specifies the property
905
- * name of the host element that will be updated. When not provided,
906
- * 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.
907
894
  *
908
895
  * @usageNotes
909
- * ### Example
910
896
  *
911
- * The following example creates a directive that sets the `valid` and `invalid` classes
912
- * 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.
913
899
  *
914
900
  * ```typescript
915
901
  * @Directive({selector: '[ngModel]'})
916
902
  * class NgModelStatus {
917
- * constructor(public control:NgModel) {}
903
+ * constructor(public control: NgModel) {}
918
904
  * @HostBinding('class.valid') get valid() { return this.control.valid; }
919
905
  * @HostBinding('class.invalid') get invalid() { return this.control.invalid; }
920
906
  * }
@@ -933,12 +919,12 @@ export interface HostBindingDecorator {
933
919
  }
934
920
  /**
935
921
  * Type of the HostBinding metadata.
922
+ *
936
923
  */
937
924
  export interface HostBinding {
938
925
  hostPropertyName?: string;
939
926
  }
940
927
  /**
941
- * HostBinding decorator and metadata.
942
928
  *
943
929
  * @Annotation
944
930
  */
@@ -947,39 +933,6 @@ export declare const HostBinding: HostBindingDecorator;
947
933
  * Type of the HostListener decorator / constructor function.
948
934
  */
949
935
  export interface HostListenerDecorator {
950
- /**
951
- * Declares a host listener.
952
- *
953
- * Angular will invoke the decorated method when the host element emits the specified event.
954
- *
955
- * If the decorated method returns `false`, then `preventDefault` is applied on the DOM event.
956
- *
957
- * @usageNotes
958
- * ### Example
959
- *
960
- * The following example declares a directive that attaches a click listener to the button and
961
- * counts clicks.
962
- *
963
- * ```typescript
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
- * ```
980
- *
981
- * @Annotation
982
- */
983
936
  (eventName: string, args?: string[]): any;
984
937
  new (eventName: string, args?: string[]): any;
985
938
  }
@@ -987,11 +940,43 @@ export interface HostListenerDecorator {
987
940
  * Type of the HostListener metadata.
988
941
  */
989
942
  export interface HostListener {
943
+ /**
944
+ * The CSS event to listen for.
945
+ */
990
946
  eventName?: string;
947
+ /**
948
+ * A set of arguments to pass to the handler method when the event occurs.
949
+ */
991
950
  args?: string[];
992
951
  }
993
952
  /**
994
- * HostListener decorator and metadata.
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
+ * ```
995
980
  *
996
981
  * @Annotation
997
982
  */