Options
All
  • Public
  • Public/Protected
  • All
Menu

Angular Template Compiler Build Status npm version

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

  1. string interpolation
  2. ng-template
  3. ng-container
  4. *ngIf + *ngIf as
  5. *ngFor
  6. [style.xxx]="value"
  7. [style.xxx.px]="value"
  8. [class.xxx]="value"

Index

Type aliases

Evaluator

Evaluator: function

Type declaration

    • (code: string): Promise<any>
    • Parameters

      • code: string

      Returns Promise<any>

Functions

applyAttributes

  • applyAttributes(element: Element, context: any, evaluator: Evaluator): Promise<undefined | function>
  • Parameters

    • element: Element
    • context: any
    • evaluator: Evaluator

    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>
  • eval expression with variables defined in context

    Parameters

    • element: Element
    • context: any
    • params: Params

    Returns Promise<boolean>

compileTemplate

  • compileTemplate(element: Element, context?: undefined | object): Promise<boolean>
  • process all angular instruction in given Element or HTMLElement return true if succeed

    Parameters

    • element: Element
    • Optional context: undefined | object

    Returns Promise<boolean>

createEvaluator

  • createEvaluator(context: object): Evaluator
  • return function to eval expression with variables defined in context

    Parameters

    • context: object
      • [variable: string]: any

    Returns Evaluator

htmlToElement

  • htmlToElement(html: string): HTMLElement

toText

  • toText(template: string, data?: any): Promise<string>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc