Fix submit on enter.

This commit is contained in:
Alexis Lahouze 2017-08-08 23:37:09 +02:00
parent e68db9f54a
commit 061cda89d0

View File

@ -10,8 +10,8 @@ import { Account } from './account';
selector: 'account-form',
exportAs: 'accountForm',
template: `
<form class="form-horizontal simple-form" novalidate
(ngSubmit)="submit()" [formGroup]="form">
<form novalidate
(keyup.enter)="submit()" [formGroup]="form">
<div class="form-group row">
<label class="col-sm-5 control-label" [for]="name.key">Account name</label>
@ -74,7 +74,9 @@ export class AccountFormComponent implements OnInit {
}
submit() {
this.submitEventEmitter.emit();
if(this.form.valid) {
this.submitEventEmitter.emit();
}
}
get name() {