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.
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.
FormField Association
The following example demonstrates how to use the Upload within a FormField component and provide hint and error messages.