Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!