0

I want to create a dropdown using angular PrimeNG as my web page language selector. I already create using angular material but this time I want to create using PrimeNG.

toolbar.component.html <p-dropdown [options]="lang" [(ngModel)]="selectedLang" optionLabel="name" optionValue="code" (change)="changeLang('code')"></p-dropdown>

toolbar.component.ts

import { Component, OnInit } from '@angular/core';


interface Language {
  name: string,
  code: string
}


@Component({
  selector: 'app-toolbar',
  templateUrl: './toolbar.component.html',
  styleUrls: ['./toolbar.component.scss']
})
export class ToolbarComponent implements OnInit {

  lang: Language[];

  selectedLang: Language | undefined;

  constructor(private translateConfigService: TranslateConfigService) { 
    
    this.lang = [
      {name: 'English', code: 'en',},
      {name: '日本語', code: 'jp'}
  ];
  }

  ngOnInit(): void {
    
  }

  changeLang(type: string){
    this.translateConfigService.changeLanguage(type);
  }

} ```
  • 1
    Can you provide what is your problem, what you attempt and what you have failed to do ? – Axiome Oct 13 '21 at 08:21
  • I would like to use the dropdown to select the language to display in the web content. We are currently using priming material. If you have selected Japanese then web content should change to Japanese. I would like to create a method for that. –  Oct 19 '21 at 07:13

0 Answers0