Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<h5>{{ componentVariable }}</h5>
<h5>{{ componentVariableSecond }}</h5>
<label for="lang">Choose a language:</label>
<select (change)="onChange($" id="lang">
<option *ngFor='let l of languages' [value]="l.code">{{l.label | transloco }}</option>
import { Component, OnInit } from '@angular/core';
import { TranslocoService } from '@ngneat/transloco';
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.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