Angular2 Reactive Forms. Set the default value for the form input field (input type = file)?

I need to set the default image path in formbuilder, but with an exception. I also tried an empty string and null.

 buildForm() {
        this.userForm = this.formBuilder.group({
            location_id: this.formBuilder.control(null),
            image: this.formBuilder.control('assets/images-demo/avatars/user.png'),
        });
    }

ERROR DOMException: Failed to set the 'value' property to "HTMLInputElement": this input element accepts a file name that can only programmatically set an empty string.

+4
source share
1 answer

The error indicates that the program does not enter input for type='file'.

Only an empty string is possible.

Many posts say that it is a security issue to change the input value for a type file.

jQuery, Input FILE, INPUT

+3

Source: https://habr.com/ru/post/1676253/


All Articles