How to handle file upload using Angular2 Formbuilder?

There seems to be a lack of proper documentation in the Angular documentation. Angular2 final release is still young, so there is not much information on the Internet.

I would appreciate it if someone could help me handle file uploads using FormBuilder component in Angular 2.1

+5
source share
1 answer

Fast and complete the task (modify according to your needs):

// Inside component fileUploaded(event: any) { const file = event.srcElement.files[0]; this.form.get('file').patchValue(file); } // Inside template <input type="file" (change)="fileUploaded($event)"> 
0
source

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


All Articles