Compiler

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.

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>> clearCache(): void clearCacheFor(type: Type<any>) getModuleId(moduleType: Type<any>): string | undefined }

说明

Each @NgModule provides an own Compiler to its injector, that will use the directives/pipes of the ng module for compilation of components.

方法

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>

参数

moduleType

Type: Type.

返回值

NgModuleFactory<T>

Compiles the given NgModule and all of its components

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

参数

moduleType

Type: Type.

返回值

Promise<NgModuleFactory<T>>

Same as compileModuleSync but also creates ComponentFactories for all components.

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

参数

moduleType

Type: Type.

返回值

ModuleWithComponentFactories<T>

Same as compileModuleAsync but also creates ComponentFactories for all components.

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

参数

moduleType

Type: Type.

返回值

Promise<ModuleWithComponentFactories<T>>

Clears all caches.

clearCache(): void

参数

没有参数。

返回值

void

Clears the cache for the given component/ngModule.

clearCacheFor(type: Type<any>)

参数

type

Type: Type.

Returns the id for a given NgModule, if one is defined and known to the compiler.

getModuleId(moduleType: Type<any>): string | undefined

参数

moduleType

Type: Type.

返回值

string | undefined

注解

@Injectable()