Search Posts

Category: local-storage

Localstorage is working for first time. If I refresh page at second it is working fine

Am using Angular ng-storage. Am facing an issue with local storage. At first when page is loaded the localstorage is assigning with null value. If I refresh at second time localstorage value is setting fine. I dono what the issue. My code is. var app = angular.module(‘EntityApp’, [‘ngRoute’,’slickCarousel’]); app.controller(‘EntityAppCntroller’, function ($scope, $http, $window) { localStorage.IsNewPinSet = 22; if (localStorage.getItem(‘IsNewPinSet’) != 1) { var getLocation = function() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { alert(“Geolocation […]

Use condition with two for values

I wanna use show / hide div function with localStorage. So I wrote this code scope: function getLocalDatas (clickedBefore, data, nid, vote, advpoll_choice, title, element) { for(var nid in actualPolls){ var nids = []; var nids = JSON.stringify(actualPolls[nid].nid); // console.log(‘id ‘+ ids); console.log(‘here ‘+ nids); } for(var i in localStorage){ var ids = JSON.stringify(localStorage[i]); // console.log(‘id ‘+ ids); console.log(‘nid ‘+ ids); } if(ids == nids) { console.log(‘ids ‘+ids); vm.clickedBefore = true; console.log(vm.clickedBefore); console.log(“done”); } else […]

How to use localStorage value filter in ng-repeat

I’ve set a value when the user click vote choice. Its working. .then(function(response) { localStorage.setItem(‘isClicked’, ‘Yes’); var i = +localStorage.key(“nid”); var nidId = ‘nid’ + localStorage.length; localStorage.setItem(nidId, vm.nid); vm.clickedBefore = true; }) This is my HTML scope: <div class=”card myfunc” ng-repeat=”myfunc in myfuncPage.myfuncs” id=”{{myfunc.nid}}” > <div class=”item item-text-wrap”> <h2 class=”item-icon-left”><i class=”icon ion-ios-analytics”></i> {{myfunc.title}}</h2> </div> <div class=”item item-text-wrap” ng-show=”localstorage”> <img ng-src=”{{myfunc.field_image.und[0].imgPath}}”/> <p class=”custom-class” ng-bind-html=’myfunc.body.und[0].value’> </p> <ul ng-repeat=”vote in myfunc.advmyfunc_choice”> <li ng-repeat=”voteselect in vote”> <div class=”row”> <button […]