frontend-tutorial-framework/src/app/app.component.ts

26 lines
789 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { config } from './config';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
documentTitle: string = config.documentTitle;
constructor(private titleService: Title) {}
ngOnInit() {
this.titleService.setTitle(this.documentTitle);
if (config.dashboard.askReloadSite) {
window.addEventListener('beforeunload', (event) => {
const confirmationMessage = 'Refreshing this page may mess up your challenge/tutorial state. Are you sure?';
event.returnValue = confirmationMessage;
return confirmationMessage;
});
}
}
}