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