Angular Template Compiler
Compile your Angular 2.x - Angular 8.x templates for print, emails, etc
Usage
let data = { name: 'Roman' };
let element = htmlToElement(`<div>{{name}}</div>`);
await compileTemplate(result, data);
Features
- string interpolation
- ng-template
- ng-container
- *ngIf + *ngIf as
- *ngFor
- [style.xxx]="value"
- [style.xxx.px]="value"
- [class.xxx]="value"
Type aliases
Evaluator
Evaluator: function
Type declaration
-
- (code: string): Promise<any>
-
Parameters
Returns Promise<any>
Functions
applyAttributes
- applyAttributes(element: Element, context: any, evaluator: Evaluator): Promise<undefined | function>
-
Parameters
-
element: Element
-
context: any
-
Returns Promise<undefined | function>
compile
- compile(template: string, data?: any): Promise<HTMLElement>
-
Parameters
-
template: string
-
Optional data: any
Returns Promise<HTMLElement>
compileElement
- compileElement(element: Element, context: any, params: Params): Promise<boolean>
-
Parameters
-
element: Element
-
context: any
-
Returns Promise<boolean>
compileTemplate
- compileTemplate(element: Element, context?: undefined | object): Promise<boolean>
-
Parameters
-
element: Element
-
Optional context: undefined | object
Returns Promise<boolean>
htmlToElement
- htmlToElement(html: string): HTMLElement
-
Parameters
Returns HTMLElement
toText
- toText(template: string, data?: any): Promise<string>
-
Parameters
-
template: string
-
Optional data: any
Returns Promise<string>
eval expression with variables defined in context