toddmo
toddmo

Reputation: 22416

How to clear $localStorage

In Angular I tried:

$localStorage.clear();

It got the error:

$localStorage.clear is not a function

What is the correct calling convention to wipe out $localStorage?

Upvotes: 2

Views: 4572

Answers (2)

Túlio Castro
Túlio Castro

Reputation: 1323

If you are using ngStorage you can try $localStorage.$reset(); instead clear().

This method clear is the default HTML5 method, to use it you have to take off $, eg: localStorage.clear()

Upvotes: 5

Estus Flask
Estus Flask

Reputation: 222538

As the manual says,

$localStorage.$reset();

Upvotes: 9

Related Questions