I have button that I want to disable when local storage is empty
<button ng-show="LS_wimmtkey!==null">{{LS_wimmtkey}}</button>
Button value shows null, but it is shown, why could that be? I tried writing ng-show="1===2"
when it worked correctly, so the problem is with LS_wimmtkey
this is how I use it:
in main.controller.js
:
$rootScope.LS_wimmtkey = localStorage.getItem('LS_wimmtkey');
$rootScope.$watch("LS_wimmtkey", function() {
localStorage.setItem('LS_wimmtkey', $rootScope.LS_wimmtkey);
My main.view is inserted into the review.view (because form and reviews are on the same page, main is for the review listing and reviews are submitted form)
I add values to local storage after submit in review.controller.js
function submit() {
if($rootScope.name!=null) {
var JSONObject = {
"name":$rootScope.name,
"surname":$rootScope.surname,
"email":$rootScope.email,
"review":$rootScope.review
}
var temp={
"name":$rootScope.name,
"surname":$rootScope.surname,
"email":$rootScope.email
}
$scope.localArray.push(temp);
$rootScope.LS_wimmtkey = $scope.localArray;
// $rootScope.localStorageService.set("LS_wimmtkey", $scope.localArray);debugger;
// $rootScope.LS_wimmtkey= localStorageService.get("LS_wimmtkey"); debugger;
var Results = UniversalService.PostReview(JSON.stringify(JSONObject));
}
}
I print console.log($rootScope.LS_wimmtkey);
and it is null, so why button is not hidden?