// vim: set tw=80 ts=2 sw=2 sts=2 : import { AfterViewChecked, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { NgForm } from '@angular/forms'; import { Operation } from './operation'; @Component({ selector: 'operation-form', template: `
` }) export class OperationFormComponent implements AfterViewChecked { @Input() operation: Operation; @Output() onValid: EventEmitter = new EventEmitter(); @ViewChild('form') form: NgForm; //dateMask = [/\d{4}/, '-', /0[1-9]|1[0-2]/, '-', /[0-2]\d|3[0-1]/]; dateMask = ['2', '0', /\d/, /\d/, '-', /[0-1]/, /\d/, '-', /[0-3]/, /\d/]; constructor() {} ngAfterViewChecked() { this.onValid.emit(this.form.form.valid); } }