Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocalStorage

Represents the native localStorage object. Can be injected into a component that needs access to localStorage.

Hierarchy

Implements

  • OnDestroy
  • Storage

Indexable

[key: string]: any

Gets or set a value from storage. Unlike getItem and setItem, the value is not required to be a string. All values will be serialized to string prior to being stored. To specify serialization, {@link StorageOptions#transformer}

Index

Constructors

constructor

Accessors

length

  • get length(): number

Methods

clear

  • clear(): void

getItem

  • getItem(key: string): string
  • Retrieves data stored is storage.

    Parameters

    • key: string

      The identifier used to locate data in storage.

    Returns string

Protected getProperty

  • getProperty<T>(name: string): T

key

  • key(index: number): string
  • Retrieves an identifier

    Parameters

    • index: number

      The position at which to look for an identifier. Index be at least zero and must be less than length.

    Returns string

ngOnDestroy

  • ngOnDestroy(): void

removeItem

  • removeItem(key: string): void

setItem

  • setItem(key: string, value: string): void
  • Stores data in storage

    Parameters

    • key: string

      The identifier to associate stored data with

    • value: string

      The data to place in storage

    Returns void

Protected setProperty

  • setProperty(name: string, value: any): void
  • Stores data in a private private property that will not be stored in storage. This is necessary because creating a class property results in an extra key in storage.

    Parameters

    • name: string
    • value: any

    Returns void

Generated using TypeDoc