UNPKG

@angular/core

Version:

Angular - the core framework

1,517 lines (1,446 loc) 497 kB
/** * @license Angular v8.2.9 * (c) 2010-2019 Google LLC. https://angular.io/ * License: MIT */ import { Observable } from 'rxjs'; import { Subject } from 'rxjs'; import { Subscription } from 'rxjs'; /** * @description * * Represents an abstract class `T`, if applied to a concrete class it would stop being * instantiatable. * * @publicApi */ export declare interface AbstractType<T> extends Function { prototype: T; } /** * Below are constants for LContainer indices to help us look up LContainer members * without having to remember the specific indices. * Uglify will inline these when minifying so there shouldn't be a cost. */ declare const ACTIVE_INDEX = 2; /** * @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/lifecycle-hooks#onchanges) guide * * @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/lifecycle-hooks#onchanges) guide * * @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/lifecycle-hooks#onchanges) guide * * @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/lifecycle-hooks#onchanges) guide * * @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 */ export declare const ANALYZE_FOR_ENTRY_COMPONENTS: InjectionToken<any>; /** * All callbacks provided via this token will be called for every component that is bootstrapped. * Signature of the callback: * * `(componentRef: ComponentRef) => void`. * * @publicApi */ export declare const APP_BOOTSTRAP_LISTENER: InjectionToken<((compRef: ComponentRef<any>) => void)[]>; /** * A DI Token representing a unique string id assigned to the application by Angular and used * primarily for prefixing application attributes and CSS styles when * {@link ViewEncapsulation#Emulated ViewEncapsulation.Emulated} is being used. * * If you need to avoid randomly generated value to be used as an application id, you can provide * a custom value via a DI provider <!-- TODO: provider --> configuring the root {@link Injector} * using this token. * @publicApi */ export declare const APP_ID: InjectionToken<string>; /** * A function that will be executed when an application is initialized. * * @publicApi */ export declare const APP_INITIALIZER: InjectionToken<(() => void)[]>; /** * A class that reflects the state of running {@link APP_INITIALIZER}s. * * @publicApi */ export declare class ApplicationInitStatus { private appInits; private resolve; private reject; private initialized; readonly donePromise: Promise<any>; readonly done = false; constructor(appInits: (() => any)[]); } /** * 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 _console; private _injector; private _exceptionHandler; private _componentFactoryResolver; private _initStatus; private _bootstrapListeners; private _views; private _runningTick; private _enforceNoNewChanges; private _stable; /** * Get a list of component types registered to this application. * This list is populated even before the component is created. */ readonly componentTypes: Type<any>[]; /** * Get a list of components registered to this application. */ readonly components: ComponentRef<any>[]; /** * 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<boolean>; /** * Bootstrap a new component at the root level of the application. * * @usageNotes * ### Bootstrap process * * When bootstrapping a new root component into an application, Angular mounts the * specified application component onto DOM elements identified by the componentType's * selector and kicks off automatic change detection to finish initializing the component. * * Optionally, a component can be mounted onto a DOM element that does not match the * componentType's selector. * * ### Example * {@example core/ts/platform/platform.ts region='longform'} */ bootstrap<C>(componentOrFactory: ComponentFactory<C> | Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C>; /** * 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; private _unloadComponent; /** * Returns the number of attached views. */ readonly viewCount: number; } /** * @publicApi */ export declare function asNativeElements(debugEls: DebugElement[]): any; /** * Checks that there currently is a platform which 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 `<input>` element and want to know its `type`. * * ```html * <input type="text"> * ``` * * The following example uses the decorator to inject the string literal `text`. * * {@example core/ts/metadata/metadata.ts region='attributeMetadata'} * * ### Example as TypeScript Decorator * * {@example core/ts/metadata/metadata.ts region='attributeFactory'} * */ (name: string): any; new (name: string): Attribute; } declare const BINDING_INDEX = 7; 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'; } declare const BRAND = "__SANITIZER_TRUSTED_BRAND__"; declare const enum BypassType { Url = "Url", Html = "Html", ResourceUrl = "ResourceUrl", Script = "Script", Style = "Style" } /** * The strategy that the default change detector uses to detect changes. * When set, takes effect the next time change detection is triggered. * * @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 } /** * Base class for Angular Views, 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 rerendered. * * @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](http://plnkr.co/edit/GC512b?p=preview). * * <code-example path="core/ts/change_detect/change-detection.ts" * region="mark-for-check"></code-example> * * ### 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. * * <code-example path="core/ts/change_detect/change-detection.ts" region="detach"></code-example> * * * ### 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. * * <code-example path="core/ts/change_detect/change-detection.ts" region="reattach"></code-example> * * @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. * * <!-- TODO: Add a link to a chapter on OnPush components --> * */ 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. * * <!-- TODO: Add a link to a chapter on detach/reattach/local digest --> * <!-- TODO: Add a live demo once ref.detectChanges is merged into master --> * */ abstract detach(): void; /** * Checks this view and its children. Use in combination with {@link ChangeDetectorRef#detach * detach} * to implement local change detection checks. * * <!-- TODO: Add a link to a chapter on detach/reattach/local digest --> * <!-- TODO: Add a live demo once ref.detectChanges is merged into master --> * */ 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. * * <!-- TODO: Add a link to a chapter on detach/reattach/local digest --> * */ abstract reattach(): void; } declare const CHILD_HEAD = 14; declare const CHILD_TAIL = 15; /** * 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<any>; } declare const CLEANUP = 8; /** * @deprecated v4.0.0 - Use IterableChangeRecord instead. * @publicApi */ export declare interface CollectionChangeRecord<V> extends IterableChangeRecord<V> { } /** * Marks that the next string is for comment. * * See `I18nMutateOpCodes` documentation. */ declare const COMMENT_MARKER: COMMENT_MARKER; declare interface COMMENT_MARKER { marker: 'comment'; } /** * Compile an Angular injectable according to its `Injectable` metadata, and patch the resulting * `ngInjectableDef` onto the injectable type. */ declare function compileInjectable(type: Type<any>, srcMeta?: 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: <T>(moduleType: Type<T>) => NgModuleFactory<T>; /** * Compiles the given NgModule and all of its components */ compileModuleAsync: <T>(moduleType: Type<T>) => Promise<NgModuleFactory<T>>; /** * Same as {@link #compileModuleSync} but also creates ComponentFactories for all components. */ compileModuleAndAllComponentsSync: <T>(moduleType: Type<T>) => ModuleWithComponentFactories<T>; /** * Same as {@link #compileModuleAsync} but also creates ComponentFactories for all components. */ compileModuleAndAllComponentsAsync: <T>(moduleType: Type<T>) => Promise<ModuleWithComponentFactories<T>>; /** * Clears all caches. */ clearCache(): void; /** * Clears the cache for the given component/ngModule. */ clearCacheFor(type: Type<any>): void; /** * Returns the id for a given NgModule, if one is defined and known to the compiler. */ getModuleId(moduleType: Type<any>): string | undefined; } /** * Token to provide CompilerOptions in the platform injector. * * @publicApi */ export declare const COMPILER_OPTIONS: InjectionToken<CompilerOptions[]>; /** * 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.Native`: Deprecated. Use `ViewEncapsulation.ShadowDom` instead. * - `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 encapsulation 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}. */ entryComponents?: Array<Type<any> | 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 per an 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. * * <code-example path="core/ts/metadata/directives.ts" region="component-input"></code-example> * * * ### 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: `<needs-greeter></needs-greeter>` * }) * 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 * <button>Action 1</button> <button>Action 2</button> * ``` * * becomes: * * ```html * <button>Action 1</button><button>Action 2</button> * ``` * * * Replaces a series of whitespace characters in text nodes with a single space. * For example, `<span>\n some text\n</span>` becomes `<span> some text </span>`. * * Does NOT alter text nodes inside HTML tags such as `<pre>` or `<textarea>`, * where whitespace characters are significant. * * Note that these transformations can influence DOM nodes layout, although impact * should be minimal. * * You can override the default behavior to preserve whitespace characters * in certain fragments of a template. For example, you can exclude an entire * DOM sub-tree by using the `ngPreserveWhitespaces` attribute: * * ```html * <div ngPreserveWhitespaces> * whitespaces are preserved here * <span> and here </span> * </div> * ``` * * You can force a single space to be preserved in a text node by using `&ngsp;`, * which is replaced with a space character by Angular's template * compiler: * * ```html * <a>Spaces</a>&ngsp;<a>between</a>&ngsp;<a>links.</a> * <!-->compiled to be equivalent to:</> * <a>Spaces</a> <a>between</a> <a>links.</a> * ``` * * Note that sequences of `&ngsp;` are still collapsed to just one space character when * the `preserveWhitespaces` option is set to `false`. * * ```html * <a>before</a>&ngsp;&ngsp;&ngsp;<a>after</a> * <!-->compiled to be equivalent to:</> * <a>Spaces</a> <a>between</a> <a>links.</a> * ``` * * To preserve sequences of whitespace characters, use the * `ngPreserveWhitespaces` attribute. * * @Annotation */ (obj: Component): TypeDecorator; /** * See the `Component` decorator. */ new (obj: Component): Component; } declare interface ComponentDefFeature { <T>(componentDef: ɵComponentDef<T>): void; /** * Marks a feature as something that {@link InheritDefinitionFeature} will execute * during inheritance. * * NOTE: DO NOT SET IN ROOT OF MODULE! Doing so will result in tree-shakers/bundlers * identifying the change as a side effect, and the feature will be included in * every bundle. */ ngInherit?: true; } /** * Base class for a factory that can create a component dynamically. * Instantiate a factory for a given type of component with `resolveComponentFactory()`. * Use the resulting `ComponentFactory.create()` method to create a component of that type. * * @see [Dynamic Components](guide/dynamic-component-loader) * * @publicApi */ declare abstract class ComponentFactory<C> { /** * The component's HTML selector. */ abstract readonly selector: string; /** * The type of component the factory will create. */ abstract readonly componentType: Type<any>; /** * Selector for all <ng-content> elements in the component. */ abstract readonly ngContentSelectors: string[]; /** * The inputs of the component. */ abstract readonly inputs: { propName: string; templateName: string; }[]; /** * The outputs of the component. */ abstract readonly outputs: { propName: string; templateName: string; }[]; /** * Creates a new component. */ abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any, ngModule?: NgModuleRef<any>): ComponentRef<C>; } export { ComponentFactory } export { ComponentFactory as ɵComponentFactory } /** * A simple registry that maps `Components` to generated `ComponentFactory` classes * that can be used to create instances of components. * Use to obtain the factory for a given component type, * then use the factory's `create()` method to create a component of that type. * * @see [Dynamic Components](guide/dynamic-component-loader) * @publicApi */ export declare abstract class ComponentFactoryResolver { static NULL: ComponentFactoryResolver; /** * Retrieves the factory object that creates a component of the given type. * @param component The component type. */ abstract resolveComponentFactory<T>(component: Type<T>): ComponentFactory<T>; } declare type ComponentInstance = {}; /** * Represents a component created by a `ComponentFactory`. * Provides access to the component instance and related objects, * and provides the means of destroying the instance. * * @publicApi */ export declare abstract class ComponentRef<C> { /** * The host or anchor [element](guide/glossary#element) for this component instance. */ abstract readonly location: ElementRef; /** * The [dependency injector](guide/glossary#injector) for this component instance. */ abstract readonly injector: Injector; /** * This component instance. */ abstract readonly instance: C; /** * The [host view](guide/glossary#view-tree) defined by the template * for this component instance. */ abstract readonly hostView: ViewRef; /** * The change detector for this component instance. */ abstract readonly changeDetectorRef: ChangeDetectorRef; /** * The type of this component (as created by a `ComponentFactory` class). */ abstract readonly componentType: Type<any>; /** * Destroys the component instance and all of the data structures associated with it. */ abstract destroy(): void; /** * A lifecycle hook that provides additional developer-defined cleanup * functionality for the component. * @param callback A handler function that cleans up developer-defined data * associated with this component. Called when the `destroy()` method is invoked. */ abstract onDestroy(callback: Function): void; } /** * Definition of what a template rendering function should look like for a component. */ declare type ComponentTemplate<T> = { <U extends T>(rf: ɵRenderFlags, ctx: T | U): void; }; /** * Configures the `Injector` to return an instance of a token. * * @see ["Dependency Injection Guide"](guide/dependency-injection). * * @usageNotes * * {@example core/di/ts/provider_spec.ts region='ConstructorProvider'} * * ### Multi-value example * * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'} * * @publicApi */ export declare interface ConstructorProvider extends ConstructorSansProvider { /** * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`. */ provide: Type<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 an instance of a token. * * @see ["Dependency Injection Guide"](guide/dependency-injection). * * @usageNotes * * ```ts * @Injectable(SomeModule, {deps: []}) * class MyService {} * ``` * * @publicApi */ export declare interface ConstructorSansProvider { /** * A list of `token`s to be resolved by the injector. */ deps?: any[]; } /** * Type of the ContentChild metadata. * * @publicApi */ export declare type ContentChild = Query; /** * ContentChild decorator and metadata. * * * @Annotation * * @publicApi */ export declare const ContentChild: ContentChildDecorator; /** * Type of the ContentChild decorator / constructor function. * * @publicApi */ export declare interface ContentChildDecorator { /** * Parameter decorator that configures a content query. * * Use to get the first element or the directive matching the selector from the content DOM. * If the content DOM changes, and a new child matches the selector, * the property will be updated. * * Content queries are set before the `ngAfterContentInit` callback is called. * * Does not retrieve elements or directives that are in other components' templates, * since a component's template is always a black box to its ancestors. * * **Metadata Properties**: * * * **selector** - The directive type or the name used for querying. * * **read** - True to read a different token from the queried element. * * **static** - True to resolve query results before change detection runs, * false to resolve after change detection. * * When `static` is not provided, uses the query results to determine the timing of query * resolution. If any query results are inside a nested view (such as `*ngIf`), the query is * resolved after change detection runs. Otherwise, it is resolved before change detection * runs. * * @usageNotes * * {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'} * * ### Example * * {@example core/di/ts/contentChild/content_child_example.ts region='Component'} * * @Annotation */ (selector: Type<any> | Function | string, opts: { read?: any; static: boolean; }): any; new (selector: Type<any> | Function | string, opts: { read?: any; static: boolean; }): ContentChild; } /** * Type of the ContentChildren metadata. * * * @Annotation * @publicApi */ export declare type ContentChildren = Query; /** * ContentChildren decorator and metadata. * * * @Annotation * @publicApi */ export declare const ContentChildren: ContentChildrenDecorator; /** * Type of the ContentChildren decorator / constructor function. * * @see `ContentChildren`. * @publicApi */ export declare interface ContentChildrenDecorator { /** * Parameter decorator that configures a content query. * * Use to get the `QueryList` of elements or directives from the content DOM. * Any time a child element is added, removed, or moved, the query list will be * updated, and the changes observable of the query list will emit a new value. * * Content queries are set before the `ngAfterContentInit` callback is called. * * Does not retrieve elements or directives that are in other components' templates, * since a component's template is always a black box to its ancestors. * * **Metadata Properties**: * * * **selector** - The directive type or the name used for querying. * * **descendants** - True to include all descendants, otherwise include only direct children. * * **read** - True to read a different token from the queried elements. * * @usageNotes * * Here is a simple demonstration of how the `ContentChildren` decorator can be used. * * {@example core/di/ts/contentChildren/content_children_howto.ts region='HowTo'} * * ### Tab-pane example * * Here is a slightly more realistic example that shows how `ContentChildren` decorators * can be used to implement a tab pane component. * * {@example core/di/ts/contentChildren/content_children_example.ts region='Component'} * * @Annotation */ (selector: Type<any> | Function | string, opts?: { descendants?: boolean; read?: any; }): any; new (selector: Type<any> | Function | string, opts?: { descendants?: boolean; read?: any; }): Query; } /** * Definition of what a content queries function should look like. */ declare type ContentQueriesFunction<T> = <U extends T>(rf: ɵRenderFlags, ctx: U, directiveIndex: number) => void; declare const CONTEXT = 9; /** Options that control how the component should be bootstrapped. */ declare interface CreateComponentOptions { /** Which renderer factory to use. */ rendererFactory?: RendererFactory3; /** A custom sanitizer instance */ sanitizer?: Sanitizer; /** A custom animation player handler */ playerHandler?: ɵPlayerHandler; /** * Host element on which the component will be bootstrapped. If not specified, * the component definition's `tag` is used to query the existing DOM for the * element to bootstrap. */ host?: RElement | string; /** Module injector for the component. If unspecified, the injector will be NULL_INJECTOR. */ injector?: Injector; /** * List of features to be applied to the created component. Features are simply * functions that decorate a component with a certain behavior. * * Typically, the features in this list are features that cannot be added to the * other features list in the component definition because they rely on other factors. * * Example: `LifecycleHooksFeature` is a function that adds lifecycle hook capabilities * to root components in a tree-shakable way. It cannot be added to the component * features list because there's no way of knowing when the component will be used as * a root component. */ hostFeatures?: HostFeature[]; /** * A function which is used to schedule change detection work in the future. * * When marking components as dirty, it is necessary to schedule the work of * change detection in the future. This is done to coalesce multiple * {@link markDirty} calls into a single changed detection processing. * * The default value of the scheduler is the `requestAnimationFrame` function. * * It is also useful to override this function for testing purposes. */ scheduler?: (work: () => void) => void; } /** * Creates a platform. * Platforms have to be eagerly created via this function. * * @publicApi */ export declare function createPlatform(injector: Injector): PlatformRef; /** * Creates a factory for a platform * * @publicApi */ export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null, name: string, providers?: StaticProvider[]): (extraProviders?: StaticProvider[]) => PlatformRef; /** * Expresses a single CSS Selector. * * Beginning of array * - First index: element name * - Subsequent odd indices: attr keys * - Subsequent even indices: attr values * * After SelectorFlags.CLASS flag * - Class name values * * SelectorFlags.NOT flag * - Changes the mode to NOT * - Can be combined with other flags to set the element / attr / class mode * * e.g. SelectorFlags.NOT | SelectorFlags.ELEMENT * * Example: * Original: `div.foo.bar[attr1=val1][attr2]` * Parsed: ['div', 'attr1', 'val1', 'attr2', '', SelectorFlags.CLASS, 'foo', 'bar'] * * Original: 'div[attr1]:not(.foo[attr2]) * Parsed: [ * 'div', 'attr1', '', * SelectorFlags.NOT | SelectorFlags.ATTRIBUTE 'attr2', '', SelectorFlags.CLASS, 'foo' * ] * * See more examples in node_selector_matcher_spec.ts */ declare type CssSelector = (string | SelectorFlags)[]; /** * Defines a schema that allows an NgModule to contain the following: * - Non-Angular elements named with dash case (`-`). * - Element properties named with dash case (`-`). * Dash case is the naming convention for custom elements. * * @publicApi */ export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata; /** * @publicApi */ export declare interface DebugElement extends DebugNode { readonly name: string; readonly properties: { [key: string]: any; }; readonly attributes: { [key: string]: string | null; }; readonly classes: { [key: string]: boolean; }; readonly styles: { [key: string]: string | null; }; readonly childNodes: DebugNode[]; readonly nativeElement: any; readonly children: DebugElement[]; query(predicate: Predicate<DebugElement>): DebugElement; queryAll(predicate: Predicate<DebugElement>): DebugElement[]; queryAllNodes(predicate: Predicate<DebugNode>): DebugNode[]; triggerEventHandler(eventName: string, eventObj: any): void; } /** * @publicApi */ export declare const DebugElement: { new (...args: any[]): DebugElement; }; declare class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugElement { constructor(nativeNode: Element); readonly nativeElement: Element | null; readonly name: string; /** * Gets a map of property names to property values for an element. * * This map includes: * - Regular property bindings (e.g. `[id]="id"`) * - Host property bindings (e.g. `host: { '[id]': "id" }`) * - Interpolated property bindings (e.g. `id="{{ value }}") * * It does not include: * - input property bindings (e.g. `[myCustomInput]="value"`) * - attribute bindings (e.g. `[attr.role]="menu"`) */ readonly properties: { [key: string]: any; }; readonly attributes: { [key: string]: string | null; }; readonly styles: { [key: string]: string | null; }; readonly classes: { [key: string]: boolean; }; readonly childNodes: DebugNode[]; readonly children: DebugElement[]; query(predicate: Predicate<DebugElement>): DebugElement; queryAll(predicate: Predicate<DebugElement>): DebugElement[]; queryAllNodes(predicate: Predicate<DebugNode>): DebugNode[]; triggerEventHandler(eventName: string, eventObj: any): void; } /** * @publicApi */ export declare class DebugEventListener { name: string; callback: Function; constructor(name: string, callback: Function); } /** * @publicApi */ export declare interf