import { Injectable } from '@angular/core' ; @ Injectable ( ) export class LocalStorage { getItem ( key , defaultValue ? ) { if ( localStorage . getItem ( key ) ) { return JSON . parse ( localStorage . getItem ( key ) as string ) ; } else { return defaultValue ; } } setItem ( key , value ) { localStorage . setItem ( key , JSON . stringify ( value ) ) ; } removeItem ( key ) { localStorage . removeItem ( key ) ; } }