Language switch is working.

This commit is contained in:
Joachim Nielandt 2018-03-25 10:59:15 +02:00
parent 0f9a1729b3
commit bb4e3e51c0
2 changed files with 17 additions and 7 deletions

View File

@ -26,19 +26,29 @@ export class LanguagetoggleComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.stateService.getLanguageFromRoute(this.route).subscribe(lang => { this.stateService.getLanguageFromRoute(this.route).subscribe(lang => {
console.log('languagetoggle gets this language: ' + lang); if(lang==null) {
console.log('(' + this.language + ')') console.log('language is null from first level route, ignoring');
return;
}
console.log('languagetoggle gets first level lang: '+lang);
if (lang === this.language) { if (lang === this.language) {
console.log('equalled (first level of route)! showing the component'); console.log('equalled (first level of route)! showing the component' + this.language);
this.show = true; this.show = true;
} else {
this.show = false;
} }
}); });
this.stateService.getLanguageFromRoute(this.route.parent).subscribe(lang => { this.stateService.getLanguageFromRoute(this.route.parent).subscribe(lang => {
console.log('languagetoggle gets this language from parent: ' + lang); if(lang==null) {
console.log('(' + this.language + ')') console.log('language is null from parent level route, ignoring');
return;
}
console.log('languagetoggle gets parent level lang: '+lang);
if (lang === this.language) { if (lang === this.language) {
console.log('equalled (parent level of route)! showing the component'); console.log('equalled (parent level of route)! showing the component ' + this.language);
this.show = true; this.show = true;
} else {
this.show = false;
} }
}); });
} }

View File

@ -23,7 +23,7 @@ export class RootComponent implements OnInit {
console.log('oninit of root component'); console.log('oninit of root component');
this.route.paramMap.subscribe(val => console.log(val)); this.route.paramMap.subscribe(val => console.log(val));
this.stateService.getLanguageFromRoute(this.route).subscribe(val => {console.log('ngoninit root' + val)}); this.stateService.getLanguageFromRoute(this.route).subscribe(val => {console.log('ngoninit root language: ' + val)});
this.pageType$ = this.stateService.getLanguageFromRoute(this.route).map(language => { this.pageType$ = this.stateService.getLanguageFromRoute(this.route).map(language => {
if (this.router.url.endsWith('posts')) { if (this.router.url.endsWith('posts')) {