UNPKG

fe-validate

Version:

angular 2+ form validate

61 lines (60 loc) 2.06 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import { Directive, Input, HostListener, EventEmitter, Output } from "@angular/core"; import { FormGroup } from "@angular/forms"; var FormValidationDirective = /** @class */ (function () { function FormValidationDirective() { } /** * @return {?} */ FormValidationDirective.prototype.onSubmit = /** * @return {?} */ function () { this.markAsTouchedAndDirty(this.formGroup); if (this.formGroup.valid) { this.validSubmit.emit(this.formGroup.value); } }; /** * @param {?} formGroup * @return {?} */ FormValidationDirective.prototype.markAsTouchedAndDirty = /** * @param {?} formGroup * @return {?} */ function (formGroup) { var _this = this; Object.keys(formGroup.controls).forEach(function (key) { if (formGroup.controls[key] instanceof FormGroup) { _this.markAsTouchedAndDirty(/** @type {?} */ (formGroup.controls[key])); } else { formGroup.controls[key].markAsDirty(); formGroup.controls[key].markAsTouched(); formGroup.controls[key].updateValueAndValidity(); } }); }; return FormValidationDirective; }()); export { FormValidationDirective }; function FormValidationDirective_tsickle_Closure_declarations() { /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */ FormValidationDirective.decorators; /** * @nocollapse * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>} */ FormValidationDirective.ctorParameters; /** @type {!Object<string,!Array<{type: !Function, args: (undefined|!Array<?>)}>>} */ FormValidationDirective.propDecorators; /** @type {?} */ FormValidationDirective.prototype.formGroup; /** @type {?} */ FormValidationDirective.prototype.validSubmit; }