Reputation: 259
I am trying to make a button to show up only when there's a table in 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:
<main ng-view>
</main>
<button onclick="exportTableToExcel('tableToCsv')" type="button contact-
button" class="btnDL" ng-show="toDLTable()">XLSX Download</button>
Upvotes: 0
Views: 70
Reputation: 369
Try this
ControllerCode
$scope.x = document.getElementsByTagName("table");
In HTML
<button onclick="exportTableToExcel('tableToCsv')" type="button contact-
button" class="btnDL" ng-if="x.length>0" ng-show="toDLTable()">XLSX Download</button>
Upvotes: 1
Reputation: 222522
Probably you need to have a div to identify,
<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
<button onclick="exportTableToExcel('tableToCsv')" type="button contact-
button" class="btnDL" ng-show="showTab">XLSX Download</button>
Upvotes: 0