@practical-angular/local-storage
v15.2.11-rc.1
Published
LocalStorage support for Angular.
Downloads
9
Readme
@practical-angular/local-storage
LocalStorage support for Angular.
Usage
Import LocalStorageModule to a module.
+ import { LocalStorageModule } from '@practical-angular/local-storage';
@NgModule({
- imports: [BrowserModule],
+ imports: [BrowserModule, LocalStorageModule],
})
Inject the service to a component.
+ import { LocalStorageService } from '@practical-angular/local-storage';
export class YourComponent {
- constructor() {}
+ constructor(private localStorageService: LocalStorageService) {}
}
Call Set / Get / Remove Clear method.
// Set item.
this.localStorageService.setItem(key, value);
// Get item
const value = this.localStorageService.getItem(key);
// Remove item
this.localStorageService.removeItem(key);
// Clear storage
this.localStorageService.clear();