libs/common/frame/src/frame-parts/small-print/small-print.component.ts
selector | frame-small-print |
styleUrls | ./small-print.component.scss |
templateUrl | ./small-print.component.html |
Properties |
constructor(smallPrintService: TalyFrameSmallPrintService)
|
||||||
Parameters :
|
container |
Type : ViewContainerRef
|
Decorators :
@ViewChild('container', {read: ViewContainerRef, static: true})
|
import {
AfterViewInit,
Component,
DestroyRef,
TemplateRef,
ViewChild,
ViewContainerRef,
inject
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { TalyFrameSmallPrintService } from '../../services/small-print.service';
@Component({
selector: 'frame-small-print',
templateUrl: './small-print.component.html',
styleUrls: ['./small-print.component.scss'],
standalone: false
})
export class SmallPrintComponent implements AfterViewInit {
@ViewChild('container', { read: ViewContainerRef, static: true }) container!: ViewContainerRef;
private destroyRef = inject(DestroyRef);
constructor(private smallPrintService: TalyFrameSmallPrintService) {}
ngAfterViewInit() {
this.smallPrintService.templateList$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
next: (templates) => this.renderTemplates(templates)
});
}
private renderTemplates(templates: TemplateRef<unknown>[]) {
this.clearContent();
templates.forEach((template) => {
this.container.createEmbeddedView(template);
});
}
private clearContent() {
this.container.clear();
}
}
<div class="small-print-view">
<ng-container #container></ng-container>
</div>
./small-print.component.scss
:host {
counter-reset: small-print;
.small-print-view {
max-width: 100%;
width: var(--grid-max-width);
}
}
:host-context(.is-stacked) {
.small-print-view {
margin-inline: auto;
}
}