Last active
April 10, 2020 18:23
-
-
Save kutanov/c50131a54dce7b0e7f70800ec75e7011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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