- Decorators: The decorators now handle a default value #43
-
Example:
- Before:
import {LocalStorage} from 'ng2-webstorage'; @Component({...}) class FooComponent implements OnInit { @LocalStorage('foobar') foobar; ngOnInit() { let storedValue = this.storage.retrieve('foobar'); if(!storedValue) this.foobar = 'default value'; } }
- After:
import {LocalStorage} from 'ng2-webstorage'; @Component({...}) class FooComponent implements OnInit { @LocalStorage('foobar', 'default value') foobar; }
- Options: The library offers a new options caseSensitive #42
-
Example:
- Before:
import {Ng2Webstorage, LocalStorage} from 'ng2-webstorage'; @NgModule({ imports: [ Ng2Webstorage.forRoot({ caseSensitive: true }) ], }) export class AppModule {} @Component({...}) class FooComponent { @LocalStorage('foobar') foobar; @LocalStorage('Foobar') Foobar; // Before 1.7 the two binding above had the same value }
- After:
import {Ng2Webstorage, LocalStorage} from 'ng2-webstorage'; @NgModule({ imports: [ Ng2Webstorage.forRoot({ caseSensitive: true }) ], }) export class AppModule {} @Component({...}) class FooComponent { @LocalStorage('foobar') foobar = 2; @LocalStorage('Foobar') Foobar = 3; show() { console.log(this.foobar); // 2 console.log(this.Foobar); // 3 } }
- ANGULAR 4 Compliant: The library is now compliant with the ng4 compiler #23
- angular: @angular/...4.0.1
- AoT compilation: Fixed forRoot method to be compliant with AoT compilations
-
Example:
- Before:
import {Ng2Webstorage, configure as WebstorageConfigure} from 'ng2-webstorage'; WebstorageConfigure({ separator: '.', prefix: 'custom' }); @NgModule({ imports: [Ng2Webstorage], }) export class AppModule {}
- After:
import {Ng2Webstorage} from 'ng2-webstorage'; @NgModule({ imports: [ Ng2Webstorage.forRoot({ separator: '.', prefix: 'custom' }) ], }) export class AppModule {}
- AoT compilation: Add configure method replacing the forRoot one for the AoT compilations #27
- Example:
- Before:
import {Ng2Webstorage} from 'ng2-webstorage'; @NgModule({ imports: [ Ng2Webstorage.forRoot({ separator: '.', prefix: 'custom' }) ], }) export class AppModule {}
- After:
import {Ng2Webstorage, configure as WebstorageConfigure} from 'ng2-webstorage'; WebstorageConfigure({ separator: '.', prefix: 'custom' }); @NgModule({ imports: [Ng2Webstorage], }) export class AppModule {}
- angular: @angular/...2.4.1
- source map: temporarily remove source map from umd version source-map-loader issue
- listener: Now listen the changes made from other windows (Localstorage only) and devtool panel #23
- angular: @angular/...2.2.0
- KeyStorageHelper: - This service is not exposed anymore. Use the module's method
forRoot
instead to configure the web storage options.
- Example:
- Before:
KeyStorageHelper.setStorageKeyPrefix('custom'); KeyStorageHelper.setStorageKeySeparator('.');
- After:
@NgModule({ imports: [ Ng2Webstorage.forRoot({ separator: '.', prefix: 'custom' }) ] }) class AppModule {}