2

我有以下json過濾NG重複不Angularjs應用程序的工作

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

而且我過濾ng-repeat如,

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

而在我的控制,我有:如果我刪除client.name : accountSearch.clientName,按ng重複篩選條件,accountsList正確根據accountNumberaccountName進行篩選。但是,如果我包含client.name : accountSearch.clientName in ng重複篩選條件,則會在控制檯中顯示以下錯誤,並且不會出現accountsList的篩選。

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 }]. 
http://errors.angularjs.org/1.4.3/$parse/syntax?p0=.&p1=is%20unexpected%2C%20expecting%20%5B%3A%5D&p2=66&p3=accounts%20%7C%20filter%3A%7B%20number%3A%20accountSearch.accountNumber%2C%20%20%20client.name%20%3A%20accountSearch.clientName%20%7D&p4=.name%20%3A%20accountSearch.clientName%20%7D 
minErr/<@http://localhost:8080/bower_components/angular/angular.js:68:12 
[email protected]://localhost:8080/bower_components/angular/angular.js:12881:1 
[email protected]://localhost:8080/bower_components/angular/angular.js:12893:1 
[email protected]://localhost:8080/bower_components/angular/angular.js:12870:9 

任何人都可以幫助如何解決它嗎?

回答

1

使用你的內聯過濾器就可以解決問題。

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

這裏是工作plnkr檢查這一點。 http://plnkr.co/edit/B3R758UjxldvZLDkxO8E?p=preview