S SmartDocs
Chuỗi bài: angular typescript 19 dòng · Cập nhật 2026-02-03

auth.service.ts

angular/examples/week05-06/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);
  }
}

Bài viết liên quan