ng2-stable-nxtc
Version:
Angular Smart Table neXtCode Version
49 lines • 2.52 kB
JavaScript
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, ComponentFactoryResolver, ViewChild, ViewContainerRef, } from '@angular/core';
import { EditCellDefault } from './edit-cell-default';
let CustomEditComponent = class CustomEditComponent extends EditCellDefault {
constructor(resolver) {
super();
this.resolver = resolver;
}
ngOnChanges(changes) {
if (this.cell && !this.customComponent) {
const componentFactory = this.resolver.resolveComponentFactory(this.cell.getColumn().editor.component);
this.customComponent = this.dynamicTarget.createComponent(componentFactory);
// set @Inputs and @Outputs of custom component
this.customComponent.instance.cell = this.cell;
this.customComponent.instance.inputClass = this.inputClass;
this.customComponent.instance.onStopEditing.subscribe(() => this.onStopEditing());
this.customComponent.instance.onEdited.subscribe((event) => this.onEdited(event));
this.customComponent.instance.onClick.subscribe((event) => this.onClick(event));
}
}
ngOnDestroy() {
if (this.customComponent) {
this.customComponent.destroy();
}
}
};
__decorate([
ViewChild('dynamicTarget', { read: ViewContainerRef }),
__metadata("design:type", Object)
], CustomEditComponent.prototype, "dynamicTarget", void 0);
CustomEditComponent = __decorate([
Component({
selector: 'table-cell-custom-editor',
template: `
<ng-template #dynamicTarget></ng-template>
`,
}),
__metadata("design:paramtypes", [ComponentFactoryResolver])
], CustomEditComponent);
export { CustomEditComponent };
//# sourceMappingURL=custom-edit.component.js.map