Now the submission has been caught by angular2 even with action= in the
You should leverage the NgSubmit directive, as described below:
In this case, when you click on the submit button, the onSubmit method of the component will be called and you'll be able to manually send data to the server using the HTTP class on Angular2:
@Component({
})
export class MyComponent {
constructor(private http:Http) {
this.data = {
name: 'some name'
(...)
};
}
onSubmit() {
this.http.post('http://someurl', JSON.stringify(this.data))
.subscribe(...);
}
}
This way you can remain in the same page page.
Edit
Following your comment, you need to disable the behavior of the NgForm directive that catches the submit event and prevents it from being propagated. See this line: https://github.com/angular/angular/blob/master/modules/%40angular/forms/src/directives/ng_form.ts#L141.
To do that simply add the ngNoForm attribute to your form:
In this case, a new window will be opened for your form submission.
Hope it helps you, Thierry