import {Injectable} from '@angular/core'; @Injectable({providedIn: 'root'}) export class LocalStorageService { get(key: string): T | null { try { const value = localStorage.getItem(key); return value ? JSON.parse(value) as T : null; } catch { return null; } } set(key: string, value: T): void { try { localStorage.setItem(key, JSON.stringify(value)); } catch { } } remove(key: string): void { localStorage.removeItem(key); } }