File

src/app/core/common-components/view-actions/view-actions.component.ts

Description

Building block for views, providing a consistent layout to action buttons and menus for both dialog and routed views.

Implements

AfterViewInit

Metadata

Index

Properties

Properties

template
Type : TemplateRef<any>
Decorators :
@ViewChild('template')
Protected viewContext
Default value : inject(ViewComponentContext, { optional: true })
import {
  AfterViewInit,
  Component,
  TemplateRef,
  ViewChild,
  inject,
} from "@angular/core";
import { NgTemplateOutlet } from "@angular/common";
import { ViewComponentContext } from "../../ui/abstract-view/view-component-context";

/**
 * Building block for views, providing a consistent layout to action buttons and menus
 * for both dialog and routed views.
 */
@Component({
  selector: "app-view-actions",
  templateUrl: "./view-actions.component.html",
  imports: [NgTemplateOutlet],
})
export class ViewActionsComponent implements AfterViewInit {
  protected viewContext = inject(ViewComponentContext, { optional: true });

  @ViewChild("template") template: TemplateRef<any>;

  ngAfterViewInit(): void {
    if (this.viewContext) {
      setTimeout(() => (this.viewContext.actions = this));
    }
  }
}
<ng-template #template>
  <ng-content></ng-content>
</ng-template>

@if (!viewContext) {
  <ng-container *ngTemplateOutlet="template"></ng-container>
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""