ng-local-session-storage
v0.2.1
Published
LocalStorage and SessionStorage service for Angular 2+. AoT compatible.
Downloads
3
Readme
ng-local-session-storage
LocalStorage and SessionStorage service for Angular 2+. AoT compatible.
Differences
- No events broadcast on $rootScope - LocalStorageService exposes observables for
errors$
,removeItems$
,setItems$
andwarning$
if you really need something to happen when something happens. - The
bind
function doesn't work anymore (there is a stub so this can still be a drop-in, but it'll do nothing).
Install
npm install ng-local-session-storage
Usage
You can optionally configure the module:
import { LocalStorageModule } from 'angular-2-local-storage';
@NgModule({
imports: [
LocalStorageModule.forRoot({
prefix: 'my-app',
storageType: 'localStorage'
})
],
declarations: [
..
],
providers: [
..
],
bootstrap: [AppComponent]
})
export class AppModule { }
Then you can use it in a component:
import { LocalStorageService } from 'angular-2-local-storage';
@Component({
// ...
})
export class SomeComponent {
constructor (
private _localStorageService: LocalStorageService
) {
// YAY!
}
}
Configuration options
import { ILocalStorageServiceConfig } from 'angular-2-local-storage';
for type information about the configuration object.
Thank
Based on angular-local-storage and angular-2-local-storage