model-form
Version:
Dynamic Form Builder for Anuglar 5 and the WAR Framework
35 lines • 1.49 kB
JavaScript
import { Component, Input, EventEmitter, Output } from '@angular/core';
import { FormBuilder } from '@angular/forms';
var ModelFormComponent = (function () {
function ModelFormComponent(fb) {
this.fb = fb;
this.map = [];
this.submitted = new EventEmitter();
}
ModelFormComponent.prototype.ngOnInit = function () { this.form = this.createGroup(); };
ModelFormComponent.prototype.createGroup = function () {
var _this = this;
var group = this.fb.group({});
this.map.forEach(function (c) { return group.addControl(c.name, _this.fb.control('')); });
return group;
};
ModelFormComponent.decorators = [
{ type: Component, args: [{
selector: 'model-form',
template: "\n\t\t<form class=\"model-form compact\" [formGroup]=\"form\" (ngSubmit)=\"submitted.emit(form.value)\">\n\t\t\t<section class=\"form-block\">\n\t\t\t\t<ng-container modelField></ng-container>\n\t\t\t</section>\n\t\t</form>\n\t",
styles: []
},] },
];
/** @nocollapse */
ModelFormComponent.ctorParameters = function () { return [
{ type: FormBuilder, },
]; };
ModelFormComponent.propDecorators = {
"map": [{ type: Input },],
"model": [{ type: Input },],
"submitted": [{ type: Output },],
};
return ModelFormComponent;
}());
export { ModelFormComponent };
//# sourceMappingURL=model-form.component.js.map