bixi
Version:
企业级中后台前端解决方案
35 lines (29 loc) • 954 B
text/typescript
import { Injectable, TemplateRef } from '@angular/core';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { EBixiCustomTplType } from '../table.type';
interface IColTemplateRows {
[key: string]: TemplateRef<NzSafeAny>;
}
()
export class ColTemplateService {
headerRows: Partial<IColTemplateRows> = {};
bodyRows: Partial<IColTemplateRows> = {};
add(colName: string, ref: TemplateRef<NzSafeAny>, type: EBixiCustomTplType) {
switch (type) {
case EBixiCustomTplType.header:
this.headerRows[colName] = ref;
break;
case EBixiCustomTplType.body:
this.bodyRows[colName] = ref;
break;
}
}
getTemplateRef(refName: string, type: EBixiCustomTplType): TemplateRef<NzSafeAny> | undefined {
switch (type) {
case EBixiCustomTplType.header:
return this.headerRows[refName];
case EBixiCustomTplType.body:
return this.bodyRows[refName];
}
}
}