js判断map是否为空

   在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">即可判断,

posted on 2015-09-17 10:50  SunJLBlog  阅读(13128)  评论(0编辑  收藏  举报

导航