Headless clear behavior for an input or textarea
CngxInputClear
DirectivePrimaryv0.1.0WCAG AA
projects/forms/input/input-clear.directive.ts
Import#
import { CngxInputClear } from '@cngx/forms/input'
Description#
Headless clear behavior for an input or textarea.
Place on a button or any element. Pass a reference to the target input. The consumer renders the UI - this directive only provides the behavior.
<input #nameInput />
<button [cngxInputClear]="nameInput" #clr="cngxInputClear">
@if (clr.hasValue()) { Clear }
</button>