src/modules/session/components/app-container.component.ts
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.
OnInit
| encapsulation | ViewEncapsulation.None |
| host | { |
| selector | stark-app-container |
| templateUrl | ./app-container.component.html |
Methods |
|
Public
constructor(logger: StarkLoggingService, routingService: StarkRoutingService)
|
||||||||||||
|
Class constructor
Parameters :
|
| 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>