For any form in Angular 2.0.1, whenever I press return or click on the submit button, the ngSubmit
output is fired twice. I'm already including the FormsModule
in the application module:
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule,
routing
],
declarations: [
// ...
],
providers: [
// ...
],
bootstrap: [AppComponent]
})
export class AppModule {}
I've tried to follow some answers (such as this one), but disableDeprecatedForms
and provideForms
have been removed since RC6. I've also tried to import the DeprecatedFormsModule
, but it seems to have been removed as well.
What should I do to prevent the ngSubmit
to be fired twice?
UPDATE:
I didn't think the template would matter in this case since it's a known issue and it happens for any form in the application, but here follow one of the forms as an example (stripped out of unnecessary classes and tags):
<form (ngSubmit)="login(user)">
<input [(ngModel)]="user.username" name="username" type="email" id="username" required>
<label for="username">Email</label>
<input [(ngModel)]="user.password" name="password" type="password" id="password" required>
<label for="password">Password</label>
<button>
Submit
</button>
</form>