src/modules/app-footer/components/app-footer.component.ts
Component to display the application's footer.
                OnInit
    
| changeDetection | ChangeDetectionStrategy.OnPush | 
| selector | stark-app-footer | 
| templateUrl | ./app-footer.component.html | 
| Properties | 
| 
 | 
| Methods | 
| 
 | 
| Inputs | 
| HostBindings | 
| Public constructor(logger: StarkLoggingService, $translate: TranslateService) | ||||||||||||
| Class constructor 
                                    Parameters :
                                     
 | 
| helpPageUrl | |
| Type : string | |
| Url for the help page | |
| legalInfoUrl | |
| Type : string | |
| Url for the Legal Information | |
| class | 
| Type : string | 
| Default value : componentName | 
| Adds class="stark-app-footer" attribute on the host component | 
| Public getCopyrightPeriod | ||||||||
| getCopyrightPeriod(startYear: string) | ||||||||
| Creates and format the copyright period based on the starting year. 
                                Parameters :
                                
                                 
 
                            Returns :          stringThe copyright period string | 
| Public getCopyrightYear | 
| getCopyrightYear() | 
| Get the copyright year located in the translation file 
                            Returns :          stringThe copyright year string | 
| Public ngOnInit | 
| ngOnInit() | 
| Component lifecycle hook 
                            Returns :          void | 
| Public $translate | 
| Type : TranslateService | 
| - The `TranslateService` instance of the application. | 
| Public class | 
| Type : string | 
| Default value : componentName | 
| Decorators : 
                            @HostBinding('class') | 
| Adds class="stark-app-footer" attribute on the host component | 
| Public copyrightPeriod | 
| Type : string | 
| Copyright period displayed. | 
| Public logger | 
| Type : StarkLoggingService | 
| Decorators : 
                            @Inject(STARK_LOGGING_SERVICE) | 
| - The `StarkLoggingService` instance of the application. | 
import { ChangeDetectionStrategy, Component, HostBinding, Inject, Input, OnInit } from "@angular/core";
import { TranslateService } from "@ngx-translate/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
/**
 * @ignore
 */
const componentName = "stark-app-footer";
/**
 * Component to display the application's footer.
 */
@Component({
	selector: "stark-app-footer",
	templateUrl: "./app-footer.component.html",
	changeDetection: ChangeDetectionStrategy.OnPush
})
export class StarkAppFooterComponent implements OnInit {
	/**
	 * Adds class="stark-app-footer" attribute on the host component
	 */
	@HostBinding("class")
	public class: string = componentName;
	/**
	 * Url for the Legal Information
	 */
	@Input()
	public legalInfoUrl?: string;
	/**
	 * Url for the help page
	 */
	@Input()
	public helpPageUrl?: string;
	/**
	 * Copyright period displayed.
	 */
	public copyrightPeriod!: string;
	/**
	 * Class constructor
	 * @param logger - The `StarkLoggingService` instance of the application.
	 * @param $translate - The `TranslateService` instance of the application.
	 */
	public constructor(
		@Inject(STARK_LOGGING_SERVICE) public logger: StarkLoggingService,
		public $translate: TranslateService
	) {
		// empty constructor
	}
	/**
	 * Component lifecycle hook
	 */
	public ngOnInit(): void {
		this.logger.debug(componentName + ": controller initialized");
		// get the copyright period based on the value in translation file
		this.copyrightPeriod = this.getCopyrightPeriod(this.getCopyrightYear());
	}
	/**
	 * Creates and format the copyright period based on the starting year.
	 * @returns The copyright period string
	 * @param startYear - The starting year of the copyright
	 */
	public getCopyrightPeriod(startYear: string): string {
		const currentYear: string = new Date().getFullYear().toString();
		if (startYear === currentYear) {
			return startYear;
		}
		return startYear + " - " + currentYear;
	}
	/**
	 * Get the copyright year located in the translation file
	 * @returns The copyright year string
	 */
	public getCopyrightYear(): string {
		return this.$translate.instant("STARK.APP_FOOTER.COPYRIGHT_YEAR");
	}
}
<footer class="stark-app-footer-container">
	<span translate>STARK.APP_FOOTER.COPYRIGHT</span> © <span>{{ copyrightPeriod }}</span>
	<span class="bullet" *ngIf="legalInfoUrl"> • </span>
	<a *ngIf="legalInfoUrl" href="{{ legalInfoUrl }}" target="_blank" rel="noopener noreferrer">
		{{ "STARK.APP_FOOTER.LEGAL_INFO" | translate }}
	</a>
	<span class="bullet" *ngIf="helpPageUrl"> • </span>
	<a *ngIf="helpPageUrl" href="{{ helpPageUrl }}" target="_blank" rel="noopener noreferrer">
		{{ "STARK.APP_FOOTER.HELP" | translate }}
	</a>
	<span class="bullet" *ngIf="footerContent.childNodes.length !== 0"> • </span>
	<span #footerContent><ng-content></ng-content></span>
</footer>