S SmartDocs
Série: angular typescript 19 lignes · Mis à jour 2026-02-03

auth.service.ts

angular/examples/week05-06/src/app/auth.service.ts

// @ts-nocheck
import { Injectable, signal } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class AuthService {
  private authenticated = signal(false);

  isAuthenticated(): boolean {
    return this.authenticated();
  }

  login(): void {
    this.authenticated.set(true);
  }

  logout(): void {
    this.authenticated.set(false);
  }
}

Articles liés