UNPKG

ng2-stable-nxtc

Version:

Angular Smart Table neXtCode Version

64 lines 2.73 kB
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); }; import { Component, Input, ComponentFactoryResolver, ViewChild, ViewContainerRef, } from '@angular/core'; import { Cell } from '../../../lib/data-set/cell'; let CustomViewComponent = class CustomViewComponent { constructor(resolver) { this.resolver = resolver; } ngOnInit() { if (this.cell && !this.customComponent) { this.createCustomComponent(); this.callOnComponentInit(); this.patchInstance(); } } ngOnDestroy() { if (this.customComponent) { this.customComponent.destroy(); } } createCustomComponent() { const componentFactory = this.resolver.resolveComponentFactory(this.cell.getColumn().renderComponent); this.customComponent = this.dynamicTarget.createComponent(componentFactory); } callOnComponentInit() { const onComponentInitFunction = this.cell.getColumn().getOnComponentInitFunction(); onComponentInitFunction && onComponentInitFunction(this.customComponent.instance); } patchInstance() { Object.assign(this.customComponent.instance, this.getPatch()); } getPatch() { return { value: this.cell.getValue(), rowData: this.cell.getRow().getData() }; } }; __decorate([ Input(), __metadata("design:type", Cell) ], CustomViewComponent.prototype, "cell", void 0); __decorate([ ViewChild('dynamicTarget', { read: ViewContainerRef }), __metadata("design:type", Object) ], CustomViewComponent.prototype, "dynamicTarget", void 0); CustomViewComponent = __decorate([ Component({ selector: 'custom-view-component', template: ` <ng-template #dynamicTarget></ng-template> `, }), __metadata("design:paramtypes", [ComponentFactoryResolver]) ], CustomViewComponent); export { CustomViewComponent }; //# sourceMappingURL=custom-view.component.js.map