Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cdl-localstorage

rsolanki43MIT0.0.8TypeScript support: included

This is a simple local storage which is developed using javascript.

storage, angular-storage, custom storage, ng6-storage, ng7-storage, ng8-storage, local-storage, session-storage, cookie

readme

Localstorage

This is a simple local storage which is developed using javascript.

Installation instruction

npm install cdl-localstorage --save

Instruction to use the package

How to use?

Please follow below instruction to implement local storage in your angular application.

//in module
import { LocalstorageModule } from 'cdl-localstorage'; 

imports: [
    LocalstorageModule
]

// In your component ts file

import { LocalstorageService } from 'cdl-localstorage';

First way to utilize service

// Extend service to utilize its functions

export class AppComponent extends LocalstorageService {

    constructor() {
        super();
    }

    ngOnInit() {
        //Set value in local storage by key value pair
        this.setValue(key, value);

        //Get value from local storage by key
        this.getValue(key);

        //Clear specific value in local storage by key
        this.clearValue(key);

        //Clear entire local storage
        this.clearAll();
    }
}

Second way to utilize service

// Initilize service to constructor

export class AppComponent {

    constructor(private localstorageService: LocalstorageService) {
        //TODO:
    }

    ngOnInit() {
        //Set value in local storage by key value pair
        this.localstorageService.setValue(key, value);

        //Get value from local storage by key
        this.localstorageService.getValue(key);

        //Clear specific value in local storage by key
        this.localstorageService.clearValue(key);

        //Clear entire local storage
        this.localstorageService.clearAll();
    }
}