0

I am attempting to make an angularjs filter. I am filtering on three attributes. the first two are comparator false and the last is comparator true. is this possible without making a custom filter? I tried below but it throws an error.

|

 filter :
     {
        'PatientFullName' : vm.headerService.searchText,
        'Archived' : vm.headerService.Archived,
        'PhysicianID' : {vm.headerService.selectedPhysician.PhysicianID,true}
     }

here is the whole html

<div class="col-sm-6 col-md-4" ng-repeat="patient in vm.patientlist | orderBy: vm.headerService.currentSort.orderBy:vm.headerService.currentSort.sortDescending
     | filter :
     {
        'PatientFullName' : vm.headerService.searchText,
        'Archived' : vm.headerService.Archived,
        'PhysicianID' : {vm.headerService.selectedPhysician.PhysicianID,true}
     }">

here is the error

angular.js:14794 Error: [$parse:syntax] Syntax Error: Token '.' is unexpected, expecting [}] at column 263 of the expression [vm.patientlist | orderBy: vm.headerService.currentSort.orderBy:vm.headerService.currentSort.sortDescending | filter : { 'PatientFullName' : vm.headerService.searchText, 'Archived' : vm.headerService.Archived, 'PhysicianID' : {vm.headerService.selectedPhysician.PhysicianID,true} }] starting at [.headerService.selectedPhysician.PhysicianID,true} }].

1 Answer 1

1

{vm.headerService.selectedPhysician.PhysicianID,true} is not correct object. To perform filtering by different value of comparator you may chain filtering:

<div class="col-sm-6 col-md-4" ng-repeat="patient in vm.patientlist | orderBy: vm.headerService.currentSort.orderBy:vm.headerService.currentSort.sortDescending
 | filter :
 {
    'PatientFullName' : vm.headerService.searchText,
    'Archived' : vm.headerService.Archived
 }
 | filter : 
{        
    'PhysicianID' : vm.headerService.selectedPhysician.PhysicianID
}: true">

But better rewrite that into controller's method. It will improve the readability:

<div class="col-sm-6 col-md-4" 
 ng-repeat="patient in vm.patientlist | 
            orderBy: vm.headerService.currentSort.orderBy
                   : vm.headerService.currentSort.sortDescending
           |filter : vm.myFilteringMethod">
Sign up to request clarification or add additional context in comments.

Comments

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.