[英]Angularjs ng-show for table
I am trying to make a button to show up only when there's a table in ng-view. 我试图使一个按钮仅在ng-view中有表格时显示。 How do i code it to do that?
我该如何编码呢? How should the condition be written to achieve that?
要如何写条件才能实现这一目标? Thanks for the help in advance!
我在这里先向您的帮助表示感谢!
HTML: HTML:
<main ng-view>
</main>
<button onclick="exportTableToExcel('tableToCsv')" type="button contact-
button" class="btnDL" ng-show="toDLTable()">XLSX Download</button>
Try this 尝试这个
ControllerCode ControllerCode
$scope.x = document.getElementsByTagName("table");
In HTML 在HTML中
<button onclick="exportTableToExcel('tableToCsv')" type="button contact-
button" class="btnDL" ng-if="x.length>0" ng-show="toDLTable()">XLSX Download</button>
Probably you need to have a div to identify, 可能您需要一个div来标识,
<div class="view-container">
<main ng-view>
</main>
</div>
Now inside your controller, 现在在您的控制器中,
$scope.CheckContent = function(){
var theView = document.getElementsByClassName("view-container")[0].getElementById("myView").getElementsByClassName("container")[0];
if(theView != null && theView == ''){
$scope.showTab = true;
}
}
}
and bind it in HTML 并绑定到HTML
<button onclick="exportTableToExcel('tableToCsv')" type="button contact-
button" class="btnDL" ng-show="showTab">XLSX Download</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.