I am playing with angular 2, try to create a sample app that upload a file. Have below view and component, when i click submit, i don`t see any request is coming out from browser.
if i add (ngSubmit)="onSubmit()" to form, i can see onSubmit is invoked, but i don`t see anything pass into it.
Question: what is the right way to get proper binding so that i can have a valid file upload form?
Template:
<form action="api/upload" method="POST" enctype="multipart/form-data" class="btn-group" role="group">
<input type="file" class="btn btn-lg btn-default" required>
<input type="submit" value="Upload" class="btn btn-lg btn-primary upload-btn">
</form>
Component:
import {Component} from 'angular2/core';
import {FORM_DIRECTIVES} from 'angular2/common';
@Component({
selector: 'my-app',
directives: [FORM_DIRECTIVES],
template: 'path-to-template'
})
export class AppComponent {
onSubmit(e) {
// TODO: get payload from form and upload to server
console.log(e);
}
}