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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM