ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
33 lines (24 loc) • 852 B
text/typescript
import { Directive, Host, Injectable, Input, OnInit, TemplateRef } from '@angular/core';
()
export class STRowSource {
private titles: { [key: string]: TemplateRef<void> } = {};
private rows: { [key: string]: TemplateRef<void> } = {};
add(type: string, path: string, ref: TemplateRef<void>): void {
this[type === 'title' ? 'titles' : 'rows'][path] = ref;
}
getTitle(path: string): TemplateRef<void> {
return this.titles[path];
}
getRow(path: string): TemplateRef<void> {
return this.rows[path];
}
}
({ selector: '[st-row]' })
export class STRowDirective implements OnInit {
('st-row') id: string;
() type: 'title';
constructor(private ref: TemplateRef<void>, () private source: STRowSource) {}
ngOnInit(): void {
this.source.add(this.type, this.id, this.ref);
}
}