import { ChangeDetectionStrategy, Component, Input, OnInit, TemplateRef } from '@angular/core';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { EBixiCustomTplType, ICol } from '../table.type';
import { ColTemplateService } from './col-template.service';

@Component({
  selector: 'bixi-table-col-template-header',
  host: { '[class.bixi-table-col-template]': 'true' },
  template: `
    <ng-template [ngTemplateOutlet]="outletRef"></ng-template>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class BixiTableColTemplateHeaderComponent implements OnInit {
  @Input() col: ICol;

  outletRef: TemplateRef<NzSafeAny> | undefined;

  constructor(private colTemplateService: ColTemplateService) { }

  ngOnInit() {
    this.outletRef = this.colTemplateService.getTemplateRef(this.col.nameRef || '', EBixiCustomTplType.header);
  }
}
