/** * @license Angular v12.1.4 * (c) 2010-2021 Google LLC. https://angular.io/ * License: MIT */ import { Observable } from 'rxjs'; import { Subject } from 'rxjs'; import { Subscribable } from 'rxjs'; import { Subscription } from 'rxjs'; /** * @description * * Represents an abstract class `T`, if applied to a concrete class it would stop being * instantiable. * * @publicApi */ export declare interface AbstractType extends Function { prototype: T; } /** * @description * A lifecycle hook that is called after the default change detector has * completed checking all content of a directive. * * @see `AfterViewChecked` * @see [Lifecycle hooks guide](guide/lifecycle-hooks) * * @usageNotes * The following snippet shows how a component can implement this interface to * define its own after-check functionality. * * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'} * * @publicApi */ export declare interface AfterContentChecked { /** * A callback method that is invoked immediately after the * default change detector has completed checking all of the directive's * content. */ ngAfterContentChecked(): void; } /** * @description * A lifecycle hook that is called after Angular has fully initialized * all content of a directive. * Define an `ngAfterContentInit()` method to handle any additional initialization tasks. * * @see `OnInit` * @see `AfterViewInit` * @see [Lifecycle hooks guide](guide/lifecycle-hooks) * * @usageNotes * The following snippet shows how a component can implement this interface to * define its own content initialization method. * * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'} * * @publicApi */ export declare interface AfterContentInit { /** * A callback method that is invoked immediately after * Angular has completed initialization of all of the directive's * content. * It is invoked only once when the directive is instantiated. */ ngAfterContentInit(): void; } /** * @description * A lifecycle hook that is called after the default change detector has * completed checking a component's view for changes. * * @see `AfterContentChecked` * @see [Lifecycle hooks guide](guide/lifecycle-hooks) * * @usageNotes * The following snippet shows how a component can implement this interface to * define its own after-check functionality. * * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'} * * @publicApi */ export declare interface AfterViewChecked { /** * A callback method that is invoked immediately after the * default change detector has completed one change-check cycle * for a component's view. */ ngAfterViewChecked(): void; } /** * @description * A lifecycle hook that is called after Angular has fully initialized * a component's view. * Define an `ngAfterViewInit()` method to handle any additional initialization tasks. * * @see `OnInit` * @see `AfterContentInit` * @see [Lifecycle hooks guide](guide/lifecycle-hooks) * * @usageNotes * The following snippet shows how a component can implement this interface to * define its own view initialization method. * * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'} * * @publicApi */ export declare interface AfterViewInit { /** * A callback method that is invoked immediately after * Angular has completed initialization of a component's view. * It is invoked only once when the view is instantiated. * */ ngAfterViewInit(): void; } /** * A DI token that you can use to create a virtual [provider](guide/glossary#provider) * that will populate the `entryComponents` field of components and NgModules * based on its `useValue` property value. * All components that are referenced in the `useValue` value (either directly * or in a nested array or map) are added to the `entryComponents` property. * * @usageNotes * * The following example shows how the router can populate the `entryComponents` * field of an NgModule based on a router configuration that refers * to components. * * ```typescript * // helper function inside the router * function provideRoutes(routes) { * return [ * {provide: ROUTES, useValue: routes}, * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true} * ]; * } * * // user code * let routes = [ * {path: '/root', component: RootComp}, * {path: '/teams', component: TeamsComp} * ]; * * @NgModule({ * providers: [provideRoutes(routes)] * }) * class ModuleWithRoutes {} * ``` * * @publicApi * @deprecated Since 9.0.0. With Ivy, this property is no longer necessary. */ export declare const ANALYZE_FOR_ENTRY_COMPONENTS: InjectionToken; /** * A [DI token](guide/glossary#di-token "DI token definition") that provides a set of callbacks to * be called for every component that is bootstrapped. * * Each callback must take a `ComponentRef` instance and return nothing. * * `(componentRef: ComponentRef) => void` * * @publicApi */ export declare const APP_BOOTSTRAP_LISTENER: InjectionToken<((compRef: ComponentRef) => void)[]>; /** * A [DI token](guide/glossary#di-token "DI token definition") representing a unique string ID, used * primarily for prefixing application attributes and CSS styles when * {@link ViewEncapsulation#Emulated ViewEncapsulation.Emulated} is being used. * * BY default, the value is randomly generated and assigned to the application by Angular. * To provide a custom ID value, use a DI provider to configure * the root {@link Injector} that uses this token. * * @publicApi */ export declare const APP_ID: InjectionToken; /** * A [DI token](guide/glossary#di-token "DI token definition") that you can use to provide * one or more initialization functions. * * The provided functions are injected at application startup and executed during * app initialization. If any of these functions returns a Promise or an Observable, initialization * does not complete until the Promise is resolved or the Observable is completed. * * You can, for example, create a factory function that loads language data * or an external configuration, and provide that function to the `APP_INITIALIZER` token. * The function is executed during the application bootstrap process, * and the needed data is available on startup. * * @see `ApplicationInitStatus` * * @usageNotes * * The following example illustrates how to configure a multi-provider using `APP_INITIALIZER` token * and a function returning a promise. * * ``` * function initializeApp(): Promise { * return new Promise((resolve, reject) => { * // Do some asynchronous stuff * resolve(); * }); * } * * @NgModule({ * imports: [BrowserModule], * declarations: [AppComponent], * bootstrap: [AppComponent], * providers: [{ * provide: APP_INITIALIZER, * useFactory: () => initializeApp, * multi: true * }] * }) * export class AppModule {} * ``` * * It's also possible to configure a multi-provider using `APP_INITIALIZER` token and a function * returning an observable, see an example below. Note: the `HttpClient` in this example is used for * demo purposes to illustrate how the factory function can work with other providers available * through DI. * * ``` * function initializeAppFactory(httpClient: HttpClient): () => Observable { * return () => httpClient.get("https://someUrl.com/api/user") * .pipe( * tap(user => { ... }) * ); * } * * @NgModule({ * imports: [BrowserModule, HttpClientModule], * declarations: [AppComponent], * bootstrap: [AppComponent], * providers: [{ * provide: APP_INITIALIZER, * useFactory: initializeAppFactory, * deps: [HttpClient], * multi: true * }] * }) * export class AppModule {} * ``` * * @publicApi */ export declare const APP_INITIALIZER: InjectionToken Observable | Promise | void)[]>; /** * A class that reflects the state of running {@link APP_INITIALIZER} functions. * * @publicApi */ export declare class ApplicationInitStatus { private readonly appInits; private resolve; private reject; private initialized; readonly donePromise: Promise; readonly done = false; constructor(appInits: ReadonlyArray<() => Observable | Promise | void>); } /** * Configures the root injector for an app with * providers of `@angular/core` dependencies that `ApplicationRef` needs * to bootstrap components. * * Re-exported by `BrowserModule`, which is included automatically in the root * `AppModule` when you create a new app with the CLI `new` command. * * @publicApi */ export declare class ApplicationModule { constructor(appRef: ApplicationRef); } /** * A reference to an Angular application running on a page. * * @usageNotes * * {@a is-stable-examples} * ### isStable examples and caveats * * Note two important points about `isStable`, demonstrated in the examples below: * - the application will never be stable if you start any kind * of recurrent asynchronous task when the application starts * (for example for a polling process, started with a `setInterval`, a `setTimeout` * or using RxJS operators like `interval`); * - the `isStable` Observable runs outside of the Angular zone. * * Let's imagine that you start a recurrent task * (here incrementing a counter, using RxJS `interval`), * and at the same time subscribe to `isStable`. * * ``` * constructor(appRef: ApplicationRef) { * appRef.isStable.pipe( * filter(stable => stable) * ).subscribe(() => console.log('App is stable now'); * interval(1000).subscribe(counter => console.log(counter)); * } * ``` * In this example, `isStable` will never emit `true`, * and the trace "App is stable now" will never get logged. * * If you want to execute something when the app is stable, * you have to wait for the application to be stable * before starting your polling process. * * ``` * constructor(appRef: ApplicationRef) { * appRef.isStable.pipe( * first(stable => stable), * tap(stable => console.log('App is stable now')), * switchMap(() => interval(1000)) * ).subscribe(counter => console.log(counter)); * } * ``` * In this example, the trace "App is stable now" will be logged * and then the counter starts incrementing every second. * * Note also that this Observable runs outside of the Angular zone, * which means that the code in the subscription * to this Observable will not trigger the change detection. * * Let's imagine that instead of logging the counter value, * you update a field of your component * and display it in its template. * * ``` * constructor(appRef: ApplicationRef) { * appRef.isStable.pipe( * first(stable => stable), * switchMap(() => interval(1000)) * ).subscribe(counter => this.value = counter); * } * ``` * As the `isStable` Observable runs outside the zone, * the `value` field will be updated properly, * but the template will not be refreshed! * * You'll have to manually trigger the change detection to update the template. * * ``` * constructor(appRef: ApplicationRef, cd: ChangeDetectorRef) { * appRef.isStable.pipe( * first(stable => stable), * switchMap(() => interval(1000)) * ).subscribe(counter => { * this.value = counter; * cd.detectChanges(); * }); * } * ``` * * Or make the subscription callback run inside the zone. * * ``` * constructor(appRef: ApplicationRef, zone: NgZone) { * appRef.isStable.pipe( * first(stable => stable), * switchMap(() => interval(1000)) * ).subscribe(counter => zone.run(() => this.value = counter)); * } * ``` * * @publicApi */ export declare class ApplicationRef { private _zone; private _injector; private _exceptionHandler; private _componentFactoryResolver; private _initStatus; private _views; private _runningTick; private _stable; private _onMicrotaskEmptySubscription; /** * Get a list of component types registered to this application. * This list is populated even before the component is created. */ readonly componentTypes: Type[]; /** * Get a list of components registered to this application. */ readonly components: ComponentRef[]; /** * Returns an Observable that indicates when the application is stable or unstable. * * @see [Usage notes](#is-stable-examples) for examples and caveats when using this API. */ readonly isStable: Observable; /** * Bootstrap a component onto the element identified by its selector or, optionally, to a * specified element. * * @usageNotes * ### Bootstrap process * * When bootstrapping a component, Angular mounts it onto a target DOM element * and kicks off automatic change detection. The target DOM element can be * provided using the `rootSelectorOrNode` argument. * * If the target DOM element is not provided, Angular tries to find one on a page * using the `selector` of the component that is being bootstrapped * (first matched element is used). * * ### Example * * Generally, we define the component to bootstrap in the `bootstrap` array of `NgModule`, * but it requires us to know the component while writing the application code. * * Imagine a situation where we have to wait for an API call to decide about the component to * bootstrap. We can use the `ngDoBootstrap` hook of the `NgModule` and call this method to * dynamically bootstrap a component. * * {@example core/ts/platform/platform.ts region='componentSelector'} * * Optionally, a component can be mounted onto a DOM element that does not match the * selector of the bootstrapped component. * * In the following example, we are providing a CSS selector to match the target element. * * {@example core/ts/platform/platform.ts region='cssSelector'} * * While in this example, we are providing reference to a DOM node. * * {@example core/ts/platform/platform.ts region='domNode'} */ bootstrap(componentOrFactory: ComponentFactory | Type, rootSelectorOrNode?: string | any): ComponentRef; /** * Invoke this method to explicitly process change detection and its side-effects. * * In development mode, `tick()` also performs a second change detection cycle to ensure that no * further changes are detected. If additional changes are picked up during this second cycle, * bindings in the app have side-effects that cannot be resolved in a single change detection * pass. * In this case, Angular throws an error, since an Angular application can only have one change * detection pass during which all change detection must complete. */ tick(): void; /** * Attaches a view so that it will be dirty checked. * The view will be automatically detached when it is destroyed. * This will throw if the view is already attached to a ViewContainer. */ attachView(viewRef: ViewRef): void; /** * Detaches a view from dirty checking again. */ detachView(viewRef: ViewRef): void; private _loadComponent; /** * Returns the number of attached views. */ get viewCount(): number; } /** * @publicApi */ export declare function asNativeElements(debugEls: DebugElement[]): any; /** * Checks that there is currently a platform that contains the given token as a provider. * * @publicApi */ export declare function assertPlatform(requiredToken: any): PlatformRef; /** * Type of the Attribute metadata. * * @publicApi */ export declare interface Attribute { /** * The name of the attribute whose value can be injected. */ attributeName: string; } /** * Attribute decorator and metadata. * * @Annotation * @publicApi */ export declare const Attribute: AttributeDecorator; /** * Type of the Attribute decorator / constructor function. * * @publicApi */ export declare interface AttributeDecorator { /** * Parameter decorator for a directive constructor that designates * a host-element attribute whose value is injected as a constant string literal. * * @usageNotes * * Suppose we have an `` element and want to know its `type`. * * ```html * * ``` * * The following example uses the decorator to inject the string literal `text` in a directive. * * {@example core/ts/metadata/metadata.ts region='attributeMetadata'} * * The following example uses the decorator in a component constructor. * * {@example core/ts/metadata/metadata.ts region='attributeFactory'} * */ (name: string): any; new (name: string): Attribute; } declare interface BindingDef { flags: ɵBindingFlags; ns: string | null; name: string | null; nonMinifiedName: string | null; securityContext: SecurityContext | null; suffix: string | null; } /** * Provides additional options to the bootstraping process. * * */ declare interface BootstrapOptions { /** * Optionally specify which `NgZone` should be used. * * - Provide your own `NgZone` instance. * - `zone.js` - Use default `NgZone` which requires `Zone.js`. * - `noop` - Use `NoopNgZone` which does nothing. */ ngZone?: NgZone | 'zone.js' | 'noop'; /** * Optionally specify coalescing event change detections or not. * Consider the following case. * *
* *
* * When button is clicked, because of the event bubbling, both * event handlers will be called and 2 change detections will be * triggered. We can colesce such kind of events to only trigger * change detection only once. * * By default, this option will be false. So the events will not be * coalesced and the change detection will be triggered multiple times. * And if this option be set to true, the change detection will be * triggered async by scheduling a animation frame. So in the case above, * the change detection will only be triggered once. */ ngZoneEventCoalescing?: boolean; /** * Optionally specify if `NgZone#run()` method invocations should be coalesced * into a single change detection. * * Consider the following case. * * for (let i = 0; i < 10; i ++) { * ngZone.run(() => { * // do something * }); * } * * This case triggers the change detection multiple times. * With ngZoneRunCoalescing options, all change detections in an event loop trigger only once. * In addition, the change detection executes in requestAnimation. * */ ngZoneRunCoalescing?: boolean; } /** * The strategy that the default change detector uses to detect changes. * When set, takes effect the next time change detection is triggered. * * @see {@link ChangeDetectorRef#usage-notes Change detection usage} * * @publicApi */ export declare enum ChangeDetectionStrategy { /** * Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated * until reactivated by setting the strategy to `Default` (`CheckAlways`). * Change detection can still be explicitly invoked. * This strategy applies to all child directives and cannot be overridden. */ OnPush = 0, /** * Use the default `CheckAlways` strategy, in which change detection is automatic until * explicitly deactivated. */ Default = 1 } declare type ChangeDetectionStrategy_2 = number; /** * Base class that provides change detection functionality. * A change-detection tree collects all views that are to be checked for changes. * Use the methods to add and remove views from the tree, initiate change-detection, * and explicitly mark views as _dirty_, meaning that they have changed and need to be re-rendered. * * @see [Using change detection hooks](guide/lifecycle-hooks#using-change-detection-hooks) * @see [Defining custom change detection](guide/lifecycle-hooks#defining-custom-change-detection) * * @usageNotes * * The following examples demonstrate how to modify default change-detection behavior * to perform explicit detection when needed. * * ### Use `markForCheck()` with `CheckOnce` strategy * * The following example sets the `OnPush` change-detection strategy for a component * (`CheckOnce`, rather than the default `CheckAlways`), then forces a second check * after an interval. See [live demo](https://plnkr.co/edit/GC512b?p=preview). * * * * ### Detach change detector to limit how often check occurs * * The following example defines a component with a large list of read-only data * that is expected to change constantly, many times per second. * To improve performance, we want to check and update the list * less often than the changes actually occur. To do that, we detach * the component's change detector and perform an explicit local check every five seconds. * * * * * ### Reattaching a detached component * * The following example creates a component displaying live data. * The component detaches its change detector from the main change detector tree * when the `live` property is set to false, and reattaches it when the property * becomes true. * * * * @publicApi */ export declare abstract class ChangeDetectorRef { /** * When a view uses the {@link ChangeDetectionStrategy#OnPush OnPush} (checkOnce) * change detection strategy, explicitly marks the view as changed so that * it can be checked again. * * Components are normally marked as dirty (in need of rerendering) when inputs * have changed or events have fired in the view. Call this method to ensure that * a component is checked even if these triggers have not occured. * * * */ abstract markForCheck(): void; /** * Detaches this view from the change-detection tree. * A detached view is not checked until it is reattached. * Use in combination with `detectChanges()` to implement local change detection checks. * * Detached views are not checked during change detection runs until they are * re-attached, even if they are marked as dirty. * * * * */ abstract detach(): void; /** * Checks this view and its children. Use in combination with {@link ChangeDetectorRef#detach * detach} * to implement local change detection checks. * * * * */ abstract detectChanges(): void; /** * Checks the change detector and its children, and throws if any changes are detected. * * Use in development mode to verify that running change detection doesn't introduce * other changes. */ abstract checkNoChanges(): void; /** * Re-attaches the previously detached view to the change detection tree. * Views are attached to the tree by default. * * * */ abstract reattach(): void; } declare const CHILD_HEAD = 13; declare const CHILD_TAIL = 14; /** * Configures the `Injector` to return an instance of `useClass` for a token. * @see ["Dependency Injection Guide"](guide/dependency-injection). * * @usageNotes * * {@example core/di/ts/provider_spec.ts region='ClassProvider'} * * Note that following two providers are not equal: * * {@example core/di/ts/provider_spec.ts region='ClassProviderDifference'} * * ### Multi-value example * * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'} * * @publicApi */ export declare interface ClassProvider extends ClassSansProvider { /** * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`). */ provide: any; /** * When true, injector returns an array of instances. This is useful to allow multiple * providers spread across many files to provide configuration information to a common token. */ multi?: boolean; } /** * Configures the `Injector` to return a value by invoking a `useClass` function. * Base for `ClassProvider` decorator. * * @see ["Dependency Injection Guide"](guide/dependency-injection). * * @publicApi */ export declare interface ClassSansProvider { /** * Class to instantiate for the `token`. */ useClass: Type; } declare const CLEANUP = 7; /** * Compile an Angular injectable according to its `Injectable` metadata, and patch the resulting * injectable def (`ɵprov`) onto the injectable type. */ declare function compileInjectable(type: Type, meta?: Injectable): void; /** * Low-level service for running the angular compiler during runtime * to create {@link ComponentFactory}s, which * can later be used to create and render a Component instance. * * Each `@NgModule` provides an own `Compiler` to its injector, * that will use the directives/pipes of the ng module for compilation * of components. * * @publicApi */ export declare class Compiler { /** * Compiles the given NgModule and all of its components. All templates of the components listed * in `entryComponents` have to be inlined. */ compileModuleSync: (moduleType: Type) => NgModuleFactory; /** * Compiles the given NgModule and all of its components */ compileModuleAsync: (moduleType: Type) => Promise>; /** * Same as {@link #compileModuleSync} but also creates ComponentFactories for all components. */ compileModuleAndAllComponentsSync: (moduleType: Type) => ModuleWithComponentFactories; /** * Same as {@link #compileModuleAsync} but also creates ComponentFactories for all components. */ compileModuleAndAllComponentsAsync: (moduleType: Type) => Promise>; /** * Clears all caches. */ clearCache(): void; /** * Clears the cache for the given component/ngModule. */ clearCacheFor(type: Type): void; /** * Returns the id for a given NgModule, if one is defined and known to the compiler. */ getModuleId(moduleType: Type): string | undefined; } /** * Token to provide CompilerOptions in the platform injector. * * @publicApi */ export declare const COMPILER_OPTIONS: InjectionToken; /** * A factory for creating a Compiler * * @publicApi */ export declare abstract class CompilerFactory { abstract createCompiler(options?: CompilerOptions[]): Compiler; } /** * Options for creating a compiler * * @publicApi */ export declare type CompilerOptions = { useJit?: boolean; defaultEncapsulation?: ViewEncapsulation; providers?: StaticProvider[]; missingTranslation?: MissingTranslationStrategy; preserveWhitespaces?: boolean; }; /** * Supplies configuration metadata for an Angular component. * * @publicApi */ export declare interface Component extends Directive { /** * The change-detection strategy to use for this component. * * When a component is instantiated, Angular creates a change detector, * which is responsible for propagating the component's bindings. * The strategy is one of: * - `ChangeDetectionStrategy#OnPush` sets the strategy to `CheckOnce` (on demand). * - `ChangeDetectionStrategy#Default` sets the strategy to `CheckAlways`. */ changeDetection?: ChangeDetectionStrategy; /** * Defines the set of injectable objects that are visible to its view DOM children. * See [example](#injecting-a-class-with-a-view-provider). * */ viewProviders?: Provider[]; /** * The module ID of the module that contains the component. * The component must be able to resolve relative URLs for templates and styles. * SystemJS exposes the `__moduleName` variable within each module. * In CommonJS, this can be set to `module.id`. * */ moduleId?: string; /** * The relative path or absolute URL of a template file for an Angular component. * If provided, do not supply an inline template using `template`. * */ templateUrl?: string; /** * An inline template for an Angular component. If provided, * do not supply a template file using `templateUrl`. * */ template?: string; /** * One or more relative paths or absolute URLs for files containing CSS stylesheets to use * in this component. */ styleUrls?: string[]; /** * One or more inline CSS stylesheets to use * in this component. */ styles?: string[]; /** * One or more animation `trigger()` calls, containing * `state()` and `transition()` definitions. * See the [Animations guide](/guide/animations) and animations API documentation. * */ animations?: any[]; /** * An encapsulation policy for the template and CSS styles. One of: * - `ViewEncapsulation.Emulated`: Use shimmed CSS that * emulates the native behavior. * - `ViewEncapsulation.None`: Use global CSS without any * encapsulation. * - `ViewEncapsulation.ShadowDom`: Use Shadow DOM v1 to encapsulate styles. * * If not supplied, the value is taken from `CompilerOptions`. The default compiler option is * `ViewEncapsulation.Emulated`. * * If the policy is set to `ViewEncapsulation.Emulated` and the component has no `styles` * or `styleUrls` specified, the policy is automatically switched to `ViewEncapsulation.None`. */ encapsulation?: ViewEncapsulation; /** * Overrides the default interpolation start and end delimiters (`{{` and `}}`). */ interpolation?: [string, string]; /** * A set of components that should be compiled along with * this component. For each component listed here, * Angular creates a {@link ComponentFactory} and stores it in the * {@link ComponentFactoryResolver}. * @deprecated Since 9.0.0. With Ivy, this property is no longer necessary. */ entryComponents?: Array | any[]>; /** * True to preserve or false to remove potentially superfluous whitespace characters * from the compiled template. Whitespace characters are those matching the `\s` * character class in JavaScript regular expressions. Default is false, unless * overridden in compiler options. */ preserveWhitespaces?: boolean; } /** * Component decorator and metadata. * * @Annotation * @publicApi */ export declare const Component: ComponentDecorator; /** * Component decorator interface * * @publicApi */ export declare interface ComponentDecorator { /** * Decorator that marks a class as an Angular component and provides configuration * metadata that determines how the component should be processed, * instantiated, and used at runtime. * * Components are the most basic UI building block of an Angular app. * An Angular app contains a tree of Angular components. * * Angular components are a subset of directives, always associated with a template. * Unlike other directives, only one component can be instantiated for a given element in a * template. * * A component must belong to an NgModule in order for it to be available * to another component or application. To make it a member of an NgModule, * list it in the `declarations` field of the `NgModule` metadata. * * Note that, in addition to these options for configuring a directive, * you can control a component's runtime behavior by implementing * life-cycle hooks. For more information, see the * [Lifecycle Hooks](guide/lifecycle-hooks) guide. * * @usageNotes * * ### Setting component inputs * * The following example creates a component with two data-bound properties, * specified by the `inputs` value. * * * * * ### Setting component outputs * * The following example shows two event emitters that emit on an interval. One * emits an output every second, while the other emits every five seconds. * * {@example core/ts/metadata/directives.ts region='component-output-interval'} * * ### Injecting a class with a view provider * * The following simple example injects a class into a component * using the view provider specified in component metadata: * * ```ts * class Greeter { * greet(name:string) { * return 'Hello ' + name + '!'; * } * } * * @Directive({ * selector: 'needs-greeter' * }) * class NeedsGreeter { * greeter:Greeter; * * constructor(greeter:Greeter) { * this.greeter = greeter; * } * } * * @Component({ * selector: 'greet', * viewProviders: [ * Greeter * ], * template: `` * }) * class HelloWorld { * } * * ``` * * ### Preserving whitespace * * Removing whitespace can greatly reduce AOT-generated code size and speed up view creation. * As of Angular 6, the default for `preserveWhitespaces` is false (whitespace is removed). * To change the default setting for all components in your application, set * the `preserveWhitespaces` option of the AOT compiler. * * By default, the AOT compiler removes whitespace characters as follows: * * Trims all whitespaces at the beginning and the end of a template. * * Removes whitespace-only text nodes. For example, * * ```html * * ``` * * becomes: * * ```html * * ``` * * * Replaces a series of whitespace characters in text nodes with a single space. * For example, `\n some text\n` becomes ` some text `. * * Does NOT alter text nodes inside HTML tags such as `
` or `