Looking for a way to display data in an angular application using ng-repeat? Want to add and remove filters on the displayed data with a simple click? You're in luck. Implementing a toggle filter functionality is easier than you think.
If you've already started, your view might look something like this:
<ion-item class="row" ng-repeat="t in tickets">
<div class="col" ng-click="toggleFilter(t.name)">{{t.name}}</div>
</ion-item>
And your controller code could be similar to this:
.controller('TicketCtrl', function ($scope, $filter) {
$scope.toggleFilter = function (name) {
name = $filter('getSlice')(name);
alert(name);
}
});
While the alert displays the correct filtered item, the view doesn't update accordingly. This issue might stem from the child scope of ng-repeat. But fear not, there's always a solution waiting to be discovered. Any suggestions or solutions?