Reputation: 39
I have injected $window properly. But when I try to use $window.localStorage
, the object localStorage
is empty. What I am doing wrong?
Upvotes: 0
Views: 84
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