Compiler

class

npm Package @angular/core
Module import { Compiler } from '@angular/core';
Source core/src/linker/compiler.ts

Overview

class Compiler {
  compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T>
  compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>>
  compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T>
  compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>): Promise<ModuleWithComponentFactories<T>>
  getNgContentSelectors(component: Type<any>): string[]
  clearCache(): void
  clearCacheFor(type: Type<any>)
}

Description

Low-level service for running the angular compiler during runtime to create ComponentFactorys, 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.

Members

compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T>

Compiles the given NgModule and all of its components. All templates of the components listed in entryComponents have to be inlined.

compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>>

Compiles the given NgModule and all of its components

compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T>

Same as compileModuleSync but also creates ComponentFactories for all components.

compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>): Promise<ModuleWithComponentFactories<T>>

Same as compileModuleAsync but also creates ComponentFactories for all components.

getNgContentSelectors(component: Type<any>): string[]

Exposes the CSS-style selectors that have been used in ngContent directives within the template of the given component. This is used by the upgrade library to compile the appropriate transclude content in the AngularJS wrapper component.

clearCache(): void

Clears all caches.

clearCacheFor(type: Type<any>)

Clears the cache for the given component/ngModule.

Annotations

@Injectable()

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/Compiler