funky-framadate-front/src/app/app.component.ts

45 lines
1.0 KiB
TypeScript

import {Component} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {Router} from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'framadate';
//translation demo:
minutes = 12;
user = {
name: 'Arthur',
age: 42
};
private step: string;
constructor(private translate: TranslateService,
private route: Router) {
this.translate.setDefaultLang('fr');
this.route.events.subscribe((event: any) => {
// console.log('event', event);
if (event.url) {
const tab = event.url.split('/');
console.log(tab);
if (tab && tab[2]) {
this.step = tab[2];
} else {
this.step = 'home';
}
}
});
}
switchLanguage(language: string) {
this.translate.use(language);
}
}