I just got into AngularJS and I'm trying to filter a table. So far I create my table dynamically, which works fine.
HTML:
<div ng-app="tableApp" ng-controller="tableAppController">
<input type="text" class="form-control" ng-model="searchKey" placeholder="search..."/>
<div class="table-responsive">
<table class="table table-striped" id="trackingTable">
<thead>
<tr>
<th>No.r.</th>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in deviceData">
<td>{{ $index + 1 }}</td>
<td>{{x.a}}</td>
<td>{{x.b}}</td>
<td>{{x.c}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<script src="scripts/AngularJS/tableAppController.js"></script>
tableAppController.js:
var app = angular.module('tableApp', []);
app.controller('tableAppController', function ($scope) {
$scope.deviceData = [{a: "123", b: "123", c: "01.01.2001"}, {a: "dummyDeviceID2", b: "dummyCarID98", c: "01.01.2001"}];
});
I'm now trying to implement an filter, which filters data from the table based on an user input from a textfield. But only when a user types something inside the textbox ofcourse. I started to change the line <tr ng-repeat="x in deviceData"> in the html file to <tr ng-repeat="x in deviceData | filter:{'a':searchKey}"> Why is this approach not working and how can I solve this problem?