Elements
LYNX_ELEMENTS declares every Lynx element as an Angular directive, so your templates type-check. import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
Usage
- When it's needed: your editor's type checking and
ng testneed it.ng buildandng serveaddCUSTOM_ELEMENTS_SCHEMAfor you, so they pass without it. - Attributes: each directive declares its element's attributes as inputs, so
[src]="url()"type-checks. Bind any other attribute with[attr.name]. - Events aren't declared as outputs. Bind them by name, such as
(bindtap). See Handling taps and events.
API
LYNX_ELEMENTS
Every directive below, as one array for a component's imports. Each directive is also exported on its own.
LynxIf and LynxFor
Declare Lynx's own low-level <if> and <for> elements, so a template that contains them type-checks. They're unrelated to Angular's @if and @for blocks, and AngularLynx doesn't test them. Use @if and @for instead.
Attributes on every element
Every directive above, except the two form accessors, also accepts these inputs.
LYNX_FORM_ACCESSORS
Both form value accessors as one array. LYNX_ELEMENTS already contains them.
LynxInputValueAccessor and LynxTextareaValueAccessor
Connect <input> and <textarea> to reactive forms, ngModel and Signal Forms' [formField]. They switch on only when one of those form directives is on the element. Angular forms calls their members; you don't. Both classes have the same members.
onInput()
Runs on bindinput. Sends the typed text, event.detail.value, to the form control.
onBlur()
Runs on bindblur. Marks the control as touched.
writeValue()
Shows the form value in the field through the element's setValue UI method. Lynx ignores changes to the value attribute after the user has typed, so form.reset() and setValue() need this.
registerOnChange() and registerOnTouched()
Store the callbacks Angular forms passes in.
setDisabledState()
Sets or removes the element's disabled attribute.
Types
None of its own. ControlValueAccessor comes from @angular/forms.
Related
- Elements and layout: which element to use, and how they differ from HTML.
- Handling taps and events
- Forms
- Accessibility and Exposure: the shared attributes in detail.
