【发布时间】:2015-12-12 20:29:53
【问题描述】:
我只是想在 localStorage 键设置为空时隐藏某些内容,并在键不为空时显示它。密钥称为articles,我尝试检查的方式是:
$scope.isEmpty = function isEmpty() {
return localStorage.getItem('articles') !== null;
};
然后在我的html中:
<li ng-show="isEmpty()"> There is actually something to see here </li>
本地存储密钥(来自 chrome 开发工具)如下所示:
**key** **Value**
articles null
这有什么特别的原因吗?我哪里做错了?
【问题讨论】:
标签: javascript angularjs html local-storage