Olioul Islam Rahi
Olioul Islam Rahi

Reputation: 39

Why my $window.localStorage object is empty?

I have injected $window properly. But when I try to use $window.localStorage, the object localStorage is empty. What I am doing wrong? enter image description here

Upvotes: 0

Views: 84

Answers (2)

I. Ahmed
I. Ahmed

Reputation: 2534

If the local storage is empty, it doesn't mean its wrong or you are doing wrong. You can set items if required as follows:

// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("lastname");

Upvotes: 0

estevanj
estevanj

Reputation: 111

Try to use localStorage.setItem , the example: localstorage

Upvotes: 2

Related Questions