Adding JavaScript and Services to Write to LocalStorage
Learn how to access the local storage of the browser by using JavaScript.
Writing JavaScript to access localStorage
We need to write the JavaScript functions that will read to and write from the browser’s localStorage. We do this as follows:
- Right-click the
wwwroot
folder and select the “Add, New Folder” option from the menu. - Name the new folder
scripts
. - Right-click the
scripts
folder and select the “Add, New Item” option from the menu. - Enter “javascript” in the “Search” box.
- Select “JavaScript File.”
- Name the file
bweInterop.js
. - Click the “Add” button.
- Enter the following JavaScript:
Get hands-on with 1400+ tech skills courses.