Skip to content

Instantly share code, notes, and snippets.

@molcik
Last active July 13, 2018 14:16
Show Gist options
  • Save molcik/0fc89934d2f5d17b626af71ca81d03b5 to your computer and use it in GitHub Desktop.
Save molcik/0fc89934d2f5d17b626af71ca81d03b5 to your computer and use it in GitHub Desktop.
Local Storage and Session Storage in Angular

Elegant way how to use Local Storage in Angular app are decorators. So you just decorate your variable with @localStorage or @SessionStorage.

Usage

export class SomeComponent {

  /** Attributes */
  @LocalStorage
  public variableToBeStored: string;

  @SessionStorage
  public variableToBeStored: string;

}

Decorators

Examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment