Add local storage

This commit is contained in:
2025-05-14 18:30:13 +02:00
parent 6979368eda
commit 6d6460ac3e
9 changed files with 131 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage-angular';
@Injectable({
providedIn: 'root'
})
export class StorageService {
private _storage: Storage | null = null;
constructor(private storage: Storage) {}
async init() {
// If using, define drivers here: await this.storage.defineDriver(/*...*/);
const storage = await this.storage.create();
this._storage = storage;
}
// Create and expose methods that users of this service can
// call, for example:
public set(key: string, value: any) {
this._storage?.set(key, value);
}
public async getCurrentUserId() {
return await this._storage?.get('user-id');
}
}