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