Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
angular typescript - show hide tabs when switch language on website

When i switch language on the website, i want to show or hide one tab, if the language is german then show it, if any other language then hide it, my code:

ngOnInit(): void {
    this.translate.onLangChange.subscribe({next: (event: { lang: string; }) =>{
            if(event.lang && event.lang === 'de'){
                this.tabsArray =  this.tabsArray.filter((tab) => tab.label !== certainPathLabel );
            }
            else{
                const foundLabel = this.tabsArray.find((tab)=>tab.label == certainPathLabel );
                if(!foundLabel) {
                    this.tabsArray.splice(4,0, {label: certainPathLabel , route: this.routeService.generateUrl(certainPatRoute)})      
                }

            }
            this.tabs$.next(this.tabsArray);
        }

    });
}

This works only if i select german, the tab is hidden but if i then select any other language i cannot display the tab again no matter what i choose, any help?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Do you have the possibility to use a simple observable ?

isGerman$ = this.translate.onLangChange.pipe(
  map({ next: (event: { lang: string; }) } => // Are you sure for { } ?
    event.lang && event.lang === 'de'
  )
);
<tabs>
  <tab *ngIf="isGerman$ | async">German</tab>
</tabs>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda