Skip to content
Inkoxide

Search covers every page and heading of the docs. Use ↑ ↓ and ↵.

Templates

Edit this page

A template is a standalone component whose template is an <ink-document>, with CUSTOM_ELEMENTS_SCHEMA, so that Angular passes the attributes and property bindings of the elements on:

import { Component, CUSTOM_ELEMENTS_SCHEMA, input } from '@angular/core';

@Component({
  selector: 'app-receipt',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document title="Receipt">
      <ink-page size="A6" class="p-8">
        <ink-text class="text-lg font-bold">Receipt for {{ customer() }}</ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Receipt {
  readonly customer = input.required<string>();
}

Inputs, @if, @for, ng-content, dependency injection and components of your own work; a component's host element is replaced by its content. Templates are created in a root injector of their own, as an application's components are in its root: what is providedIn: 'root' is there (made once, and shared by every render), and so is LOCALE_ID, which the date, currency and number pipes read. Change detection runs once. The white space of a template is read as JSX reads it, so a document gives the same tree, and the same PDF, in every front end.

Synced from packages/angular/GUIDE.md in the inkoxide repository.