I have a webpage which displays contents of a folder/directory upon clicking on it. If the contents of a folder has files, then download button is activated. If the contents of the folder is a directory, download button is inactive.
Here is my code that is supposed to make that work. But the Download button remains active all the time and never goes inactive. Can somebody point out where I'm going wrong ?
$scope.IsFile = function(filenames){
forEach(filenames, function(filename){
if(filename.indexOf(".zip") > 1|| filename.indexOf(".txt") >1 || filename.indexOf(".xml") > 1 ) {
return true;
}
else {
return false;
}
});
};
<div class="col-md-3" id="CTP Jobs">
<div ng-click="GetListOfFilesonCTP('/home/topas/rda_app/JOBS/')">
<a href="">
<h3>
JOBS <small> <span class="btn-group"
role="group">
<button type="button" class="btn btn-default" ng-disabled="IsFile(listOfFilesOnJobs)"
ng-click="download()">Download</button>
</span>
</small>
</h3>
</a>
</div>
<table class="table table-striped"
ng-init="GetListOfFilesonCTP('/home/topas/rda_app/JOBS')">
<tr ng-repeat="jobs in listOfFilesOnJobs"
ng-click="GetListOfFilesonCTP(getPath('/home/topas/rda_app/JOBS/', jobs))">
<!--'/home/topas/rda_app/JOBS/'+ jobs + '/' -->
<td><a href="">{{jobs}}</a></td>
</tr>
</table>
</div>