Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng7-storage

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng7-storage

Share Data among multiple components in angular using browser session storage

  • 1.1.6
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-54.17%
Maintainers
1
Weekly downloads
 
Created
Source

ng-storage

Share Data among multiple components in angular using browser session storage

see Stackblitz Demo here

Angular compatibility

Angular Versionpackage version
angular 8 and below1.1.4 and below
angular 9 and above(ivy version)1.1.5 and above

Usage steps

  • Run npm i ng-storage --save in command prompt from root of your project folder
  • Add import to App Module like this import { StorageModule } from 'ng7-storage';
  • Add to imports array in app module
  imports: [
    BrowserModule,
    StorageModule
  ],
  • Then import NgStorageService service import { NgStorageService } from 'ng7-storage'; in the components that you would like to use
  • Then Initialize StorageService in the component constructor
    constructor(private StorageService: NgStorageService) {
    
    }
    

follow below methods to set and retrieve data to storage

Setting Data
 this.StorageService.setData({ key: 'key_of_data', value: res ,encrypt:optional|boolean})

Pass key value pairs to store data , and key should be valid string

NB: data format that accepted by setData method is

    export interface dataFormat {
     key: string;
     value?: any;
     encrypt?: Boolean;
     decrypt?: Boolean;
    }

NB:encrypt is a development onprogress feature and may have issues when setting data that has special characters

Getting Data

eg:

this.StorageService.getData({key: 'key_of_data',decrypt:optional|boolean})

Use getData method to retrieve data, pass key of the item

Remove Data

For removing data, we can either remove by a single key or we can remove all data at once

  • removeData method is used remove single item based on key
  • removeAll method remove all data stored

Examples :

removeData : this.StorageService.removeData('key_of_data')

removeAll : this.StorageService.removeAll()

All Available methods
 setData()
 getData()
 removeData()
 removeAll()

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Vivaldi
Vivaldi
IE11, Edgelast 8 versionslast 8 versionslast 5 versions

Built with 🔧

  • Angular

Developing 👷

  1. Clone this repo with git.
  2. Install dependencies by running npm install within the directory that you cloned (probably ng-storage).
  3. Start the development server with ng serve --o.
  4. Open development site by going to http://localhost:4200 in your browser.

Author 🔮

Edison
Edison Augusthy

💻

Keywords

FAQs

Package last updated on 03 Sep 2020

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