File

src/app/components/header/header.component.ts

Metadata

selector app-header
styleUrls header.component.css
templateUrl header.component.html

Constructor

constructor(darkModeS: DarkModeService, translate: TranslateService)

Constructs the HeaderComponent.

Parameters :
  • darkModeS
    • An instance of DarkModeService for handling dark mode.
  • translate
    • An instance of TranslateService for language translation.

Methods

toggleDarkMode
toggleDarkMode()

Toggles the application's dark mode when the dark mode button is clicked.

Returns: void
changeLanguage
changeLanguage(event: any)

Changes the application's language based on the user's selection.

Parameters :
  • event
    • The event containing the selected language.
Returns: void

Properties

lang
lang: string

Stores the selected language ('en', 'fr', 'ar').

import { Component, OnInit } from '@angular/core';
import { DarkModeService } from '../../Services/dark-mode.service';
import { TranslateService } from '@ngx-translate/core';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
  /** Stores the selected language ('en', 'fr', 'ar'). */
  lang: string = "";

  /**
   * Constructs the HeaderComponent.
   * @param darkModeS - An instance of DarkModeService for handling dark mode.
   * @param translate - An instance of TranslateService for language translation.
   */
  constructor(protected darkModeS: DarkModeService, private translate: TranslateService) {
  }

  /**
   * Initializes the component. Sets the default language to 'en'.
   */
  ngOnInit(): void {
    this.lang = "en";
  }

  /**
   * Toggles the application's dark mode when the dark mode button is clicked.
   */
  toggleDarkMode(): void {
    this.darkModeS.toggleDarkMode();
  }

  /**
   * Changes the application's language based on the user's selection.
   * @param event - The event containing the selected language.
   */
  changeLanguage(event: any) {
    this.translate.use(event.target.value);
  }
}

results matching ""

    No results matching ""