Reputation: 7103
I have gitignore in one of my log directory now i wanted to display all the file names from that directory but .gitignore
is also displaying how can i ignore that file using ng-repeat
for table and display rest of the files ?
main.html
<table>
<tr ng-repeat="file in filename_data">
<td>{{ file }}</td>
<td><button type="button" class="btn btn-primary" ng-click="downloadServerFile(file)">download</button></td>
</tr>
</table>
ctrl.js
$scope.filename_data = [".gitignore","server.log","server1.log"];
Upvotes: 1
Views: 72
Reputation: 762
Filter the array before you start looping over it.
arr = [".gitignore","server.log","server1.log"].filter(x => x != '.gitignore')
Upvotes: 0
Reputation: 17551
Several options:
You can move .gitignore
file to the root and specify path to you folder inside your .gitignore
;
You can create a Angular's custom filter and drop away filenames started with .
Like this:
<tr ng-repeat="file in filename_data | myfilter">
Take a look at this article. But be careful with modifying arrays in angular's filters. It's perhaps a bad idea
Updated:
JS:
$scope.filename_data = $scope.filename_data.filter(function(value){
return value.indexOf('.') !== 0;
})
here you can find the docs
Upvotes: 2