Skip to content

Instantly share code, notes, and snippets.

@kutanov
Last active April 10, 2020 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kutanov/c50131a54dce7b0e7f70800ec75e7011 to your computer and use it in GitHub Desktop.
Save kutanov/c50131a54dce7b0e7f70800ec75e7011 to your computer and use it in GitHub Desktop.
<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