Forms Support

You can use the Upload in template-driven or reactive forms.

The component supports the required built-in Angular validation and builds on top of that with custom restrictions for file extensions, minimum, and maximum file size.

Template-Driven Forms

The template-driven forms enable you to bind the Upload to the model by using the ngModel directive.

The following example demonstrates how to utilize the required validation and the restrictions configuration option. With these settings in place, the form will become valid when an image file is successfully uploaded.

Example
View Source
Edit In Stackblitz  
Change Theme:

Reactive Forms

The FormGroup provides a way to render reactive forms. For more details, refer to the Angular Documentation.

The following example demonstrates how to use the Upload in a reactive form.

Example
View Source
Edit In Stackblitz  
Change Theme:

FormField Association

The following example demonstrates how to use the Upload within a FormField component and provide hint and error messages.

Example
View Source
Edit In Stackblitz  
Change Theme:

In this article

Not finding the help you need?