I have a requirement where I have X number of columns.
These columns are rendered using ng-repeat TH and TD.
What I want to do is, to filter the columns**(not rows)**
EX: TypeX and TypeY are my filters in a select option and each column belongs to a Type.
Colum1 TypeX | Column2 TypeY | Column3 TypeX
data1 | data2 | data3
If I filter the above table with TypeX, I just want to see Column1 and Column3
Questions - Is this even possible?
I need this based on some requirements I received where each column has a different type
Really appreciate your help!
Thank You, Nilesh
If it helps, here is code (which does not work as expected). EDIT - This is a sample code I created using the code snippet tool
var app = angular.module("test", []);
app.controller("myTest", function($scope) {
//$scope.tableData = ['data', 'data', 'data', 'data', 'data', 'data'];
$scope.tableData = ['data1', 'data2', 'data3', 'data4', 'data5', 'data6'];
$scope.tableColumns = ['Column1', 'Column2', 'Column3', 'Column4', 'Column5', 'Column6'];
$scope.typesList = ['TypeX', 'TypeX', 'TypeY', 'TypeY', 'TypeX', 'TypeY'];
$scope.types = ["TypeX", "TypeY"];
});
//
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html ng-app="test">
<div ng-controller="myTest">
<div>
<div>
<span>Filter Type:</span>
<select ng-model="testFilter">
<option value="">--type--</option>
<option ng-repeat="t in types" value="{{t}}">{{t}}</option>
</select>
</div>
<table border="1">
<tr>
<th ng-repeat="c in tableColumns | filter:testFilter">{{c + " " + typesList[($index + 1) - 1]}}</th>
</tr>
<tr>
<td ng-repeat="d in tableData | filter:testFilter">{{d + " " + typesList[($index + 1) - 1]}}</td>
</tr>
</table>
</div>
</div>
</html>
<table>? Or can you use divs (simulating a table)?