accountant-ui/src/login/loginForm.component.ts

41 lines
945 B
TypeScript
Raw Normal View History

2017-08-04 08:32:49 +02:00
// vim: set tw=80 ts=2 sw=2 sts=2 :
2017-08-09 00:12:17 +02:00
import { Component, OnInit, OnChanges, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
2017-08-04 08:32:49 +02:00
import { Login } from './login';
@Component({
2017-08-09 00:12:17 +02:00
selector: 'login-form',
exportAs: 'loginForm',
templateUrl: './loginForm.component.html'
2017-08-04 08:32:49 +02:00
})
2017-08-09 00:11:21 +02:00
export class LoginFormComponent {
2017-08-09 00:12:17 +02:00
public form: FormGroup;
2017-08-04 08:32:49 +02:00
@Input('login-form') private login: Login
2017-08-09 00:12:17 +02:00
@Output('submit') submitEventEmitter: EventEmitter<void> = new EventEmitter<void>();
constructor(private formBuilder : FormBuilder) {}
ngOnInit() {
this.form = this.formBuilder.group({
email: ['', Validators.required],
password: ['', Validators.required]
})
}
submit() {
if(this.form.valid) {
this.submitEventEmitter.emit();
}
}
get email() {
return this.form.get('email');
}
get password() {
return this.form.get('password');
}
2017-08-04 08:32:49 +02:00
}