Save Data to Local Storage in Angular | Angular Tutorial

preview_player
Показать описание
So we have created user registration form using a reactive approach. In this video we are going to save the data of this form in the browser's local storage.

Local storage is a type of web storage that allows a site to store and access data right in the browser with no expiration date. Data stored in the browser will persist even after the browser window has been closed.
This is supported by all the major browsers which support HTML 5. Although this is not the substitute of a server based database and we will store all this information in the database later in this tutorial.

But for creating mock ups or demos to the user we can quickly create an application that can run in the browser using this local storage. But remember we can not store more than 5MB data per domain in this local storage.

You can use it to store some information related to your application i.e. city list or something that does not change frequently as a cache. So you can check the local storage in your application to fetch the city list and if a customer has already visited your application, you will not have to go back to the server to fetch the city list. That will help to load your application faster for subsequent visits. Remember, you should never ever store user sensitive data in this browser storage. .

You can support me by donating on

Thanks
Studymash
Рекомендации по теме
Комментарии
Автор

If you are getting error on below line as "Argument of type 'string | null' is not assignable to parameter of type 'string'."

users =

Add "as string" after this statement as shown below

users = as string);

It happen in angular 12 or above becuase of strict type checking enabled by default in these version. As json.parse expect string but local storage.getitem can return either string or null is the reason for this error

StudyMash
Автор

At 3:57 when I use form builder I get an following error
Error: NG01101: Expected async validator to return Promise or Observable. Are you using a synchronous validator where an async validator is expected? Find more

vikassable
Автор

I am from cdac, this course is very useful for me thanks sir..

ashwinichole
Автор

Thank you very much for all the videos. Your efforts are much appreciated.I have enjoyed the course immensely so far.

webdesignwoman
Автор

Hi. Your explanation is perfect. I would like to point you one thing that is useful for all. We created a boolean usersubmitted to activate the validation when user clicks on save button. We can use " to enforce validation in else case of our check where we are checking This will enforce the form level validation without adding a boolean and then add it on all the controls. Happy coding.

posworld
Автор

im getting error "user-login.component.html:7 ERROR TypeError: UserArray.find is not a function" from 8:16

pokefurnoX
Автор

Waw man, this is the first tutorial i've seen from you but I like your style. Not too basic yet not too complex either. Just what I was looking for!

dennisdecoene
Автор

Sir, What a tutorial!
Good understandable 👍

faisalamin
Автор

Thanks a whole lot for such valuable lessons. Am learning a lot for free.

Brmmalesela
Автор

What a great tutorial 😃❤️, super work man. 👏(liked and subscribed)

himanshubijlwan
Автор

users is not iterable issue can be resolved as
users=[user, ... Object.values(users)];

prabhgill
Автор

Hi, how to use the Id sent on URL in the update form(input tag value auto filled by the id in the url ),
Please anyone helpppp

shashankk
Автор

Thanks a lot for this very informative video SiR!!!

androidsix
Автор

Hello sir it shows property user doesn't exist in RegisterComponent

Mehtre
Автор

Users array not iterable error..pls help

ninadylan
Автор

i just noticed that the border of textbox is not turn to red when we click the submit button without fill the data

vaynard
Автор

Same value I am getting in local storage. How to correct it?

varsharanaware
Автор

Your tutorial was amazing but i am getting problem. The problem is:- same values are adding twice in local storage. How can i correct it?

ankushjassal
Автор

I am not sure if its practical to use browser local storage to store the cart. Could anyone give me advice on that?
thanks.

johnnguyen
Автор

Facing issue sir TypeError:user is not iterable
Showing error even i removed local storage data from browser

I am not able to add more than one users at a time, not appearing ... Symbol in localstorage

Suhelkhanjundalla
welcome to shbcf.ru