ng-show和localStorage行为奇怪
ng-show and localStorage behaving odd
本文关键字:localStorage ng-show 更新时间:2023-09-26
我只是想隐藏的东西,当一个localStorage键被设置为null,并显示它时,关键不为空。键被称为articles
,我试图检查的方式是:
$scope.isEmpty = function isEmpty() {
return localStorage.getItem('articles') !== null;
};
then in my html:
<li ng-show="isEmpty()"> There is actually something to see here </li>
本地存储键(从chrome开发工具)看起来像这样:
**key** **Value**
articles null
有什么特别的原因导致这不起作用吗?我哪里做错了?
localStorage
只能存储字符串值。
localStorage
将null
存储为字符串。当你使用严格比较运算符时,它将不起作用。您可以使用严格比较的字符串'null'
。
return localStorage.getItem('articles') !== 'null';
相关文章:
- 使用angularjs ng Show/ng hide显示和隐藏不同的内容
- 我需要NG-IF/NG-SWITCH还是NG-SHOW&NG-HIDE
- 如何在AngularJS视图中使用promise(ng-show)
- AngularJS:如何使用java脚本函数更改跨度的ng-show条件
- ng show和ng hide don'I don’我一秒钟都不工作
- AngularJS:使用ng-show/hide动态维护下拉列表的3种状态(InProgress、Success、Err
- ng-show内容在页面加载过程中闪烁,尽管它不是真实的,并且ng-cloak不适用于FF
- 如何验证使用 ng-repeat、ng-show(角度)动态创建的输入
- 如何使用ng-repeat与清单模型进行ng-show
- AngularJS:ng-show不适用于ng-app
- 为什么我的html节点保持类ng隐藏属性ng show=true
- AngularJS:为什么ng show没有在IE11上运行
- Angularjs ng-show not working with checkbox with default val
- Angularjs - grouping ng show
- AngularJS:隐藏<td>使用ng-hide/ng-show没有间隙
- Angularjs ng-show == Id?
- 基于参数(angular)调用特定元素上的ng show
- 只有当我导航回窗口时,angular ng show才有效
- 使ng-show/ng-hide与由Angular之外的外部源修改的localStorage一起工作
- ng-show和localStorage行为奇怪