File

src/modules/session/components/app-container.component.ts

Description

Component to coordinate the display of the init/exit states when the application starts or ends and hide the application content. For any other state it simply displays the application content hiding any init/exit state.

Implements

OnInit

Metadata

Index

Methods

Constructor

Public constructor(logger: StarkLoggingService, routingService: StarkRoutingService)

Class constructor

Parameters :
Name Type Optional Description
logger StarkLoggingService No
  • The StarkLoggingService instance of the application.
routingService StarkRoutingService No
  • The StarkRoutingService instance of the application.

Methods

Public isAppInitOrExitState
isAppInitOrExitState()

Check if the current state is an init or exit state (with "starkAppInit" or "starkAppExit" as parent state name)

Returns : boolean
Public ngOnInit
ngOnInit()

Component lifecycle hook

Returns : void
import { Component, Inject, OnInit, ViewEncapsulation } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "../../logging/services";
import { STARK_ROUTING_SERVICE, StarkRoutingService } from "../../routing/services";
import { starkAppExitStateName, starkAppInitStateName } from "../constants";

/**
 * Name of the component
 */
const componentName = "stark-app-container";

/**
 * Component to coordinate the display of the init/exit states when the application starts or ends and hide the application content.
 * For any other state it simply displays the application content hiding any init/exit state.
 */
@Component({
	selector: "stark-app-container",
	templateUrl: "./app-container.component.html",
	encapsulation: ViewEncapsulation.None,
	// eslint-disable-next-line @angular-eslint/no-host-metadata-property
	host: {
		class: componentName
	}
})
export class StarkAppContainerComponent implements OnInit {
	/**
	 * Class constructor
	 * @param logger - The `StarkLoggingService` instance of the application.
	 * @param routingService - The `StarkRoutingService` instance of the application.
	 */
	public constructor(
		@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService,
		@Inject(STARK_ROUTING_SERVICE) private routingService: StarkRoutingService
	) {}

	/**
	 * Component lifecycle hook
	 */
	public ngOnInit(): void {
		this.logger.debug(componentName + ": component initialized.");
	}

	/**
	 * Check if the current state is an init or exit state (with "starkAppInit" or "starkAppExit" as parent state name)
	 */
	public isAppInitOrExitState(): boolean {
		return (
			this.routingService.isCurrentUiStateIncludedIn(starkAppInitStateName + ".**") ||
			this.routingService.isCurrentUiStateIncludedIn(starkAppExitStateName + ".**")
		);
	}
}
<ui-view name="initOrExit" *ngIf="isAppInitOrExitState()"></ui-view>
<ng-container *ngIf="!isAppInitOrExitState()">
	<ng-content></ng-content>
</ng-container>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""