hussain hussain - 1 year ago 64
AngularJS Question

How to ignore specific data for table that is using angular ng-repeat?

I have gitignore in one of my log directory now i wanted to display all the file names from that directory but

is also displaying how can i ignore that file using
for table and display rest of the files ?


<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>


$scope.filename_data = [".gitignore","server.log","server1.log"];

Answer Source

Several options:

  1. You can move .gitignore file to the root and specify path to you folder inside your .gitignore;

  2. 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


  1. Of course you can use es5's native filter for array:


$scope.filename_data = $scope.filename_data.filter(function(value){
  return value.indexOf('.') !== 0;

here you can find the docs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download