https://github.com/phenomnomnominal/angular-2-local-storage
LocalStorageService for Angular 2 with the same API as angular-local-storage
https://github.com/phenomnomnominal/angular-2-local-storage
Last synced: about 1 month ago
JSON representation
LocalStorageService for Angular 2 with the same API as angular-local-storage
- Host: GitHub
- URL: https://github.com/phenomnomnominal/angular-2-local-storage
- Owner: phenomnomnominal
- License: mit
- Created: 2016-05-12T08:54:49.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T08:04:37.000Z (over 2 years ago)
- Last Synced: 2025-03-29T19:07:14.167Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 581 KB
- Stars: 93
- Watchers: 9
- Forks: 49
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# angular-2-local-storage
LocalStorageService for Angular with mostly the same API (and most of the code) from [angular-local-storage](https://github.com/grevory/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:
```typescript
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:
```typescript
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.