I am trying to take input a search term like so:
<div class="form-group">
<input type="text" class="form-control" ng-model="vm.search.term" placeholder="Enter search term">
</div>
And then using this search term as filter on an array of objects being rendered using ng-repeat, like so:
<tbody>
<tr ng-repeat="p in vm.items track by $index | filter: vm.search.term">
<td><a>{{p.uid}}</a></td>
<td>{{p.em}}</td>
<td>{{p.ct | date:'medium'}}</td>
</tr>
</tbody>
But in the developer's console, I am getting the following error:
dashboard-js-bundle.min.js:117 Error: [filter:notarray] http://errors.angularjs.org/1.5.5/filter/notarray?p0=0
at dashboard-js-bundle.min.js:6
at dashboard-js-bundle.min.js:161
at fn (eval at compile (dashboard-js-bundle.min.js:230), <anonymous>:4:345)
at y (dashboard-js-bundle.min.js:298)
at dashboard-js-bundle.min.js:298
at dashboard-js-bundle.min.js:141
at n.$digest (dashboard-js-bundle.min.js:142)
at n.$apply (dashboard-js-bundle.min.js:145)
at l (dashboard-js-bundle.min.js:97)
at H (dashboard-js-bundle.min.js:101)
Edit: Here is how the items array looks like:
(50) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0
:
{_id: "59d1f68dc1f8554acbb65533", __v: 0, cid: "59c89f29569cb11336420d3c", uid: "1234", em: "ap@gmai.com", …}
1
:
{_id: "59d2cd255b45b78d2108f399", uid: "2315", cid: "59c89f29569cb11336420d3c", em: "vf@gmail.com", tags: "l", …}
2
:
{_id: "59d2ce515b45b78d21090022", uid: "123", cid: "59c89f29569cb11336420d3c", em: "dan@gmail.com", tags: "h", …}
3
:
{_id: "59d2ce515b45b78d21090023", uid: "4561", cid: "59c89f29569cb11336420d3c", em: "lp@fg.com", tags: "Z", …}
4
:
{_id: "59d2d38c5b45b78d21093941", uid: "3412", cid: "59c89f29569cb11336420d3c", em: "gh@we.com", tags: "pl", …}
...
Please help me find out what I am doing wrong and how I can correct it. TIA.