When using Angular 2.0.1, I'm facing an issue where the ngSubmit
output is being triggered twice every time I press return or click on the submit button within any form. The FormsModule
has already been included in the application module as shown below:
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule,
routing
],
declarations: [
// ...
],
providers: [
// ...
],
bootstrap: [AppComponent]
})
export class AppModule {}
I've tried various solutions like disabling deprecated forms and providing forms which have been removed since RC6. Additionally, attempting to import DeprecatedFormsModule
did not solve the issue either.
What steps should I take to address this problem and prevent the ngSubmit
from firing twice?
UPDATE:
Although I thought the specific template wouldn't be relevant due to it affecting all forms in the application, here is an example of a stripped-down form structure:
<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>