[FIXED] filtering ng repeat with nested object property is not working in Angularjs application


I have the following json,

$scope.accountsList = [    {
      "id": 1,
      "number": "AFRC1234",
      "name": "ACFRYTE431", 
      "postalCode": "76565",
      "invoices": null,
      "courier": {
        "id": 1,
        "name": "UPS"
      "client": {
        "id": 1,
        "code": "FREG",
        "name": "Feranget"
    } ]

And I am filtering ng-repeat as ,

<tr ng-repeat="account in accountsList | filter:{ number: accountSearch.accountNumber,  name: accountSearch.accountName, client.name : accountSearch.clientName}">

And in my controller I have :

 $scope.accountSearch = {
                accountNumber :'',
                accountName : '',
                clientName : ''

If I delete client.name : accountSearch.clientName, in ng repeat filtering criteria, the accountsList is correctly getting filtered based on accountNumber and accountName. But when I include, client.name : accountSearch.clientName in ng repeat filter criteria, the following error is getting displayed in console and filtering of accountsList is not happening.

Error: [$parse:syntax] Syntax Error: Token '.' is unexpected, expecting [:] at column 66 of the expression [accounts | filter:{ number: accountSearch.accountNumber,   client.name : accountSearch.clientName }] starting at [.name : accountSearch.clientName }].

Can any one help how to fix it?


using your inline filter like that solves the problem.

<div ng-repeat="account in accountsList | filter:{ number: accountSearch.accountNumber,  name: accountSearch.accountName, client :{ name: accountSearch.clientName} }">

and here is the working plnkr check this .http://plnkr.co/edit/B3R758UjxldvZLDkxO8E?p=preview

Answered By – katmanco

Answer Checked By – Laura B. (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published