UNPKG

angular2-json-schema-form

Version:
64 lines 2.89 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var core_1 = require("@angular/core"); var json_schema_form_service_1 = require("../library/json-schema-form.service"); var TemplateComponent = (function () { function TemplateComponent(componentFactory, jsf) { this.componentFactory = componentFactory; this.jsf = jsf; this.newComponent = null; } TemplateComponent.prototype.ngOnInit = function () { this.updateComponent(); }; TemplateComponent.prototype.ngOnChanges = function () { this.updateComponent(); }; TemplateComponent.prototype.updateComponent = function () { if (!this.newComponent && this.layoutNode.options.template) { this.newComponent = this.widgetContainer.createComponent(this.componentFactory.resolveComponentFactory(this.layoutNode.options.template)); } if (this.newComponent) { for (var _i = 0, _a = ['layoutNode', 'layoutIndex', 'dataIndex']; _i < _a.length; _i++) { var input = _a[_i]; this.newComponent.instance[input] = this[input]; } } }; return TemplateComponent; }()); __decorate([ core_1.Input(), __metadata("design:type", Object) ], TemplateComponent.prototype, "layoutNode", void 0); __decorate([ core_1.Input(), __metadata("design:type", Array) ], TemplateComponent.prototype, "layoutIndex", void 0); __decorate([ core_1.Input(), __metadata("design:type", Array) ], TemplateComponent.prototype, "dataIndex", void 0); __decorate([ core_1.ViewChild('widgetContainer', { read: core_1.ViewContainerRef }), __metadata("design:type", core_1.ViewContainerRef) ], TemplateComponent.prototype, "widgetContainer", void 0); TemplateComponent = __decorate([ core_1.Component({ moduleId: module.id, selector: 'template-widget', template: "<div #widgetContainer></div>", }), __metadata("design:paramtypes", [core_1.ComponentFactoryResolver, json_schema_form_service_1.JsonSchemaFormService]) ], TemplateComponent); exports.TemplateComponent = TemplateComponent; //# sourceMappingURL=template.component.js.map