New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-web-storage

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-web-storage

Angular decorator to save and restore of HTML5 Local&Session Storage

  • 19.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5K
decreased by-6.7%
Maintainers
0
Weekly downloads
 
Created
Source

angular-web-storage

Angular decorator to save and restore of HTML5 Local&Session Storage

NPM version Ci

Demo

1、Usage

install angular-web-storage from npm

npm install angular-web-storage --save

2、Examples

  1. using LocalStorage or SessionStorage decorator.
import { Component } from '@angular/core';
import { LocalStorageService, SessionStorageService, LocalStorage, SessionStorage } from 'angular-web-storage';

@Component({
  selector: 'demo',
  templateUrl: './demo.component.html'
})
export class DemoComponent {
  @LocalStorage() localValue: Object = { text: `Hello ${+new Date}`};
  // 设置存储KEY,以及10个小时后过期
  @LocalStorage('newKey', 10, 'h') localValue2: Object = { text: `Hello ${+new Date}`};
  @SessionStorage() sessionValue: string = `Hello ${+new Date}`;
}
  1. using LocalStorageService or SessionStorageService service.
import { Component } from '@angular/core';
import { LocalStorageService, SessionStorageService, LocalStorage, SessionStorage } from 'angular-web-storage';

@Component({
    selector: 'demo',
    templateUrl: './demo.component.html'
})
export class DemoComponent {
  constructor(private local: LocalStorageService, private session: SessionStorageService) { }

  KEY = 'value';
  value: any = null;

  set(expired: number = 0) {
    this.local.set(this.KEY, { a: 1, now: +new Date }, expired, 's');
  }

  remove() {
    this.local.remove(this.KEY);
  }

  get() {
    this.value = this.local.get(this.KEY);
  }

  clear() {
    this.local.clear();
  }
}

Expired Time Unit

  • s Second.
  • m Minute.
  • h Hour.
  • d Day.
  • w Week(equar 7 Day).
  • y Year.
  • t Custom(unit: millisecond).

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)

FAQs

Package last updated on 24 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc