<h5>{{ componentVariable }}</h5> | |
<h5>{{ componentVariableSecond }}</h5> | |
<label for="lang">Choose a language:</label> | |
<select (change)="onChange($event.target.value)" id="lang"> | |
<option *ngFor='let l of languages' [value]="l.code">{{l.label | transloco }}</option> | |
</select> |
import { Component, OnInit } from '@angular/core'; | |
import { TranslocoService } from '@ngneat/transloco'; | |
@Component({ | |
selector: 'app-home', | |
templateUrl: './home.component.html', | |
styleUrls: ['./home.component.scss'] | |
}) | |
export class HomeComponent implements OnInit { | |
lang: string = 'en'; | |
componentVariable: string; | |
componentVariableSecond: string; | |
languages: Object[] = [ | |
{ | |
label: "English", | |
code: 'en' | |
}, | |
{ | |
label: 'Russian', | |
code: 'ru' | |
}]; | |
ngOnInit(): void { | |
this.translocoService.setActiveLang(this.lang) | |
this.componentVariable = this.translocoService.translate('hello'); | |
this.componentVariableSecond = this.translocoService.translate('dashboard.description') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment