Angularjs Store in Localstorage – ngStorage

Today, We want to share with you Angularjs Store in Localstorage – ngStorage.In this post we will show you how to use localstorage in angularjs example, hear for sessionstorage ngstorage in Angular we will give you demo and example for implement.In this post, we will learn about Store Data Locally using $localstorage in AngularJS with an example.

Angularjs Store in Localstorage – ngStorage

There are the Following The simple About Angularjs Store in Localstorage – ngStorage Full Information With Example and source code.

Also Read This πŸ‘‰   Passing data to views from routes in Laravel

As I will cover this Post with live Working example to develop $window.localstorage angularjs, so the ngstorage npm for this example is following below.

Example of the Local storage in Angularjs

app.factory('userService', ['$rootScope', function ($rootScope) {

    var service = {

        model: {
            username: '',
            useremail: ''

        SaveState: function () {
            sessionStorage.userService = angular.toJson(service.model);

        RestoreState: function () {
            service.model = angular.fromJson(sessionStorage.userService);

    $rootScope.$on("savestate", service.SaveState);
    $rootScope.$on("restorestate", service.RestoreState);

    return service;

Store Data Locally using $localstorage in AngularJS

var studentInfo = {
    firstname: "Jaydeep",
    lastname: "Gondaliya",
    website: ""

window.localStorage.set("saved", JSON.stringify(studentInfo));

var studentInfo = JSON.parse(window.localStorage.get("saved"));

Full Example : AngularJS Local Storage – ngStorage

        <script src=""></script>
        <script src="ngStorage.min.js"></script>
            var myApp = angular.module("myApp", ["ngStorage"]);
            myApp.controller("PakainfoController", function($scope, $localStorage) {

                $ = function() {
                    $localStorage.message = "Welcome to";

                $scope.load = function() {
                    $ = $localStorage.message;

    <body ng-app="myApp">
        <div ng-controller="PakainfoController">
            <button ng-click="save()">Save</button>
            <button ng-click="load()">Load</button>

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read This πŸ‘‰   mobile no validation in jquery Example


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Angularjs Store in Localstorage – ngStorage.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.