1

I have a button where I am passing the value back to the controller:

<button type="button" ng-model="activeCustomer" value="active" ng-click="getVal($event)" ng-class="{'active':activeCustomer === 'active'}" class="btn btn-default">Active</button>

Its being stored in the controller like this:

$scope.activeCustomer='active';
$scope.getVal=function(active){
        $scope.activeCustomer=active.currentTarget.value;
    }

I want to filter my list by $scope.activeCustomer if detail.activeCustomer = $scope.activeCustomer

<tr ng-repeat="detail in theRecords | orderBy:sortType:sortReverse | filter:searchCustomer" ng-click="expandCustomer(detail.theCustId)" class="drillable">
    <td>{{ detail.fullname }}</td>
    <td>{{ detail.email }}</td>
    <td>{{ detail.phone }}</td>
    <td>
      <p ng-bind="{{ detail.firstcontact }} | date:'dd/MM/yy'"></p>
    </td>
    <td>{{ detail.theMainAddress }}</td>
    <td>{{ detail.paymentType  }}</td>
    <td>{{ detail.theStatus }}</td>
    <td>{{ detail.activeCustomer }}</td>
  </tr>

any ideas?

Thanks

1
  • Have you used $filter? Commented Mar 15, 2016 at 17:28

1 Answer 1

1

You're very close with what you have.

You're already setting the activeCustomer in your controller. Just pass that to the filter.

<tr ng-repeat="detail in theRecords | 
    orderBy:sortType:sortReverse | filter:activeCustomer">
Sign up to request clarification or add additional context in comments.

2 Comments

wow I cant believe that works I've been struggling with this for ages! Thanks!! It looks like it doesn't match the exact value though... when i search "inactive" it only shows inactive records but searching "active" returns both active and incative. Do you know any way to resolve this? Thanks :)
Sure! There's a second parameter you can pass to the filter to determine how the comparison happens. Just passing 'true' should work. filter: activeCustomer : true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.