Getting StartedInstall and bootstrap headless foundations 4
FormHeadless input and selection contracts 19
LayoutHeadless structural primitives for expandable and container patterns 6
NavigationHeadless trails, trees, menus, and command surfaces 7
OverlayHeadless modal and floating layer behavior 3
FeedbackHeadless notification and status communication patterns 5
UtilityReusable action, identity, and clipboard behavior 6

API reference

tngFileUpload is a standalone directive that makes its host a drop zone, validates dropped files, and reports accepted and rejected results back to the owner.

Directive selector

The primitive attaches through [tngFileUpload] and exports itself as tngFileUpload. It works on any section-like host element.

Directive attachment

html
<div
  tngFileUpload
  [accept]="'image/*,.pdf'"
  [maxSize]="5 * 1024 * 1024"
  (filesSelected)="onFilesSelected($event)"
></div>

Inputs and outputs

NameTypeNotes
acceptstring | string[] | null Comma-separated or array of tokens: extensions (.pdf), exact MIME types (application/pdf), or wildcard groups (image/*). Empty means no restriction.
multiplebooleanWhen false, the first valid file is accepted and the rest are rejected as multiple.
maxSizenumber | nullMaximum size in bytes. Zero, negative, and null values disable size validation.
disabledbooleanDisabled drop zones are fully passive: no preventDefault, no emits.
filesSelectedTngFileUploadSelectedEventEmits { files, source } when one or more valid files are selected.
filesRejectedTngFileUploadRejectedEventEmits { rejected, accepted, source } when files fail validation.
dragStateChange'idle' | 'dragging' | 'rejected'Emits whenever the drag interaction state changes.

Drag and drop behavior

  • The host remains the drop target even when the pointer releases over nested markup such as labels, icons, or hint text inside the zone.
  • Drag state is not reset when the pointer moves between the host and its descendants; only a true exit from the zone clears data-dragging.
  • Accepted and rejected file outputs are scheduled inside Angular's zone so owner templates update as soon as the drop completes.

Validation model

Each file is checked for type first, then size. Only files that pass both are considered for acceptance, and the multiple rule is applied last. Input order is preserved within both the accepted and rejected lists.

Reading rejected files

ts
// filesSelected → { files: File[]; source: "drop" | "input" }
// filesRejected → { rejected: TngFileUploadRejectedFile[]; accepted: File[]; source }

protected onFilesRejected(event: TngFileUploadRejectedEvent): void {
  for (const item of event.rejected) {
    // item.reason: "type" | "size" | "multiple" | "disabled" | "empty"
    console.warn(item.reason, item.message, item.file.name);
  }
}