API reference
TngFileUploadDirective is a headless behavior directive — no wrapper component is required. Apply it to any element and wire the inputs and outputs directly on the host.
Directive
Selector: [tngFileUpload] · Export: tngFileUpload
Inputs
| Input | Type | Default | Notes |
|---|---|---|---|
accept | string | string[] | [] | Accepted file types as extensions (.png), exact MIME types (image/png), or wildcard MIME groups (image/*). A string value is split on commas. An empty array allows all types. |
multiple | boolean | false | Permits selecting more than one file at once. Extra files dropped when false are rejected with reason multiple. |
maxSize | number | null | null | Maximum allowed file size in bytes. null disables size checking. Files exceeding this limit are rejected with reason size. |
disabled | boolean | false | Makes the drop zone fully passive — drag events are ignored and no outputs are emitted. Reflects data-disabled on the host element. |
Outputs
| Output | Payload type | Notes |
|---|---|---|
filesSelected | TngFileUploadSelectedEvent | Emitted when one or more files pass validation. Payload contains files: readonly File[] and source: 'drop' | 'input'. |
filesRejected | TngFileUploadRejectedEvent | Emitted when one or more files fail validation. Payload contains rejected: readonly TngFileUploadRejectedFile[] (each with file, reason, and message) and the co-emitted accepted files for correlation. |
dragStateChange | TngFileUploadDragState | Emitted whenever the drag interaction state transitions between 'idle', 'dragging', and 'rejected'. |
Public state
| Member | Type | Notes |
|---|---|---|
dragState | Signal<TngFileUploadDragState> | Reactive drag state readable via the tngFileUpload template reference. Useful when template-driven feedback is preferred over the output event. |
Drag and drop behavior
- Drops are accepted when the pointer releases over the host or any nested content inside the zone. The directive listens on the host and processes bubbled
dropevents from descendants. - Moving between the host and its child elements does not prematurely clear
data-dragging—dragleaveevents whoserelatedTargetis still inside the host are ignored. - File selection outputs are emitted inside Angular's zone so signal- and template-bound feedback (for example an
@ifstatus line) updates immediately after drop without requiring a follow-up pointer move.
Type reference
| Type | Definition |
|---|---|
TngFileUploadDragState | 'idle' | 'dragging' | 'rejected' |
TngFileUploadSource | 'drop' | 'input' |
TngFileUploadRejectReason | 'disabled' | 'multiple' | 'type' | 'size' | 'empty' |
TngFileUploadRejectedFile | { file: File; reason: TngFileUploadRejectReason; message: string } |
TngFileUploadSelectedEvent | { files: readonly File[]; source: TngFileUploadSource } |
TngFileUploadRejectedEvent | { rejected: readonly TngFileUploadRejectedFile[]; accepted: readonly File[]; source: TngFileUploadSource } |