import {Component, Input, OnInit} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; import {StateService} from '../../services/state.service'; @Component({ selector: 'app-languagetoggle', templateUrl: './languagetoggle.component.html', styleUrls: ['./languagetoggle.component.scss'] }) export class LanguagetoggleComponent implements OnInit { /** * This is the language for which the component is defined. Typically, when the currently set language is equal to this variable, * the component will be visible. */ @Input() private language: string; /** * if this is set to true, the component will be visible */ private show: boolean; constructor(private route: ActivatedRoute, private stateService: StateService) { } ngOnInit() { this.stateService.getLanguageFromRoute(this.route).subscribe(lang => { console.log('languagetoggle gets this language: '+ lang); console.log('('+this.language+')') if (lang === this.language) { console.log('equalled! showing the component'); this.show = true; } else { console.log('not equalled! not showing the component'); this.show = false; } }); } }