This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LocalStorageModule } from '@ngx-pwa/local-storage'; | |
| @NgModule({ | |
| imports: [ | |
| BrowserModule, | |
| LocalStorageModule | |
| ] | |
| }) | |
| export class AppModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LocalStorage } from '@ngx-pwa/local-storage'; | |
| @Injectable() | |
| export class YourService { | |
| constructor(protected localStorage: LocalStorage) {} | |
| ngOnInit() { | |
| this.localStorage.setItem('lang', 'fr').subscribe(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| System.config({ | |
| map: { | |
| '@angular/core': 'node_modules/@angular/core/bundles/core.umd.js', | |
| 'angular-async-local-storage': 'node_modules/angular-async-local-storage/bundles/async-local-storage.umd.js' | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.localStorage.setItem('color', 'red').subscribe(() => { | |
| // Done | |
| }, () => { | |
| // Error | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let user = { firstName: 'Henri', lastName: 'Bergson' }; | |
| this.localStorage.setItem('user', user).subscribe(() => {}, () => {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.localStorage.removeItem('user').subscribe(() => {}, () => {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.localStorage.clear().subscribe(() => {}, () => {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.localStorage.getItem('notexisting').subscribe((data) => { | |
| data; // null | |
| }, () => { | |
| // Not called | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.localStorage.getItem('user').subscribe((user) => { | |
| if (user != null) { | |
| user.firstName; | |
| } | |
| }, () => {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.localStorage.getItem('color').subscribe((color: string) => { | |
| color; | |
| }, () => {}); |
OlderNewer