Johnathan Mackney Johnathan Mackney - 2 years ago 63
AngularJS Question

Boolean Value on Filter in Angular Not Returning Records

I am currently in an angular/node environment. I have added the boolean value of true to my filter such that I get an exact match (I am using angular 1.5.5). however, when I add this value no records show. I am curious as to why this is, as both fields that are supposed to match are of the same data type and there are no other errors.
Here is the line that is giving trouble:

<tr ng-repeat="call in calls | filter:{clientid:clientiD}:true | orderBy:'createdAt'">

Where clientid is an integer field of the call table, and clientiD is defined as so:

$scope.clientiD = document.location.href.split('callog/')[1];

Where it is getting the parameter of the client id from the client table, which too is an integer

Answer Source

The problem is not in boolean exact mutch, but in expression of filter. You can fix it this way:
In a view: ng-repeat="call in calls | filter:callsFilter:true | orderBy:'createdAt'"
And in controller:

$scope.callsFilter = {clientid:document.location.href.split('callog/')[1]};

Update: The original expression didn't work because angular treated clientiD in {clientid:clientiD} as value and not as variable on $scope

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download