Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

angular-2-local-storage

phenomnomnominal33kMIT3.0.2TypeScript support: included

LocalStorageService for Angular 2 with mostly the same API (and most of the code) from angular-local-storage

readme

angular-2-local-storage

LocalStorageService for Angular with mostly the same API (and most of the code) from angular-local-storage.

AoT compatible.

Differences

  • No events broadcast on $rootScope - LocalStorageService exposes observables for errors$, removeItems$, setItems$ and warning$ 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 angular-2-local-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.

changelog

4.0.0 (2020-07-09)

Breaking changes

  • Updated dependencies - now using Angular ^10.0.0 and RxJs ^6.6.0

2.0.0 (2018-05-04)

Chore

  • changelog: added this file

Breaking changes

  • Updated dependencies - now using Angular ^6.0.0 and RxJs ^6.0.0

1.x.x

The past is a mystery, check the repo history