#AngularJS

Cookies or LocalStorage Service in AngularJS

When you develop a web application, sometimes you need store data in client-side. In this case, you can use cookies or local storage. Some browsers do not support local storage (eg. IE 7,8), you should use cookies, but if you are building a phonegap application, local storage is unique choice.

The below code is coffee scripts, this is an anglarjs service that you can use to get, set or remove data from/to local storage.

And the below is an AngularJS service that will write data to cookies for the case the browser does not support local storage.