Search code examples
local-storageangular4-forms

Angular when page gets refresh how to make loaclstorage values null


Here im storing pagination values in localstorage.When my page is Refresh how can i make localStorage value to null

localStorage.setItem('Hello',page);

when my page refresh it should null


Solution

  • You could clear the storage on page load with something like

    localStorage.clear(); // Will clear ALL keys

    or

    localStorage.removeItem('Hello'); // Will clear only 'Hello'