首页 > Web开发 > 详细

js判断map是否为空

时间:2015-09-17 11:30:06      阅读:926      评论:0      收藏:0      [点我收藏+]

   在HTML页面要判断后台传来的map是否为空,无论有没有内容,在fireBug中始终显示obj{...},  <table class="table table-hover list-table" ng-if="proxyView.clusterStatus==null">或<table class="table table-hover list-table" ng-if="!proxyView.clusterStatus">

<table class="table table-hover list-table" ng-if="proxyView.clusterStatus.length>0">均无法判断,

  最终看到网友的方法感觉很是有效,首先设置一个标志位,并将值设置为true,然后循环遍历这个map,如果进入循环,则说明map非空,在循环中把标志位设置为false,具体代码如下:

proxyView.isempty = true;
for ( var name in cluster ) {
proxyView.isempty = false;
}
然后使用<table class="table table-hover list-table" ng-if="proxyView.isempty">即可判断,

js判断map是否为空

原文:http://www.cnblogs.com/query-Sql/p/4815636.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!