angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

unique filter broken with multi-word parameters?

Open kanethal opened this issue 9 years ago • 2 comments

Hello, I have JSON data that includes multi-word parameters. When I try the unique filter in my ng-repeat I get the error that the second word in the parameter is an unexpected token.

Does the unique filter support multi-word keys/parameters? I've tried wrapping in single quotes, double curly braces to no avail.

(in the following, histConfig.column is a scope variable referring to a multi-word key in importedData) ng-repeat="row in importedData | uniq:histConfig.column"

error msg: Error: [$parse:syntax] Syntax Error: Token 'Provider' is an unexpected token at column 11 of the expression [Referring Provider] starting at [Provider].

kanethal avatar Feb 19 '16 08:02 kanethal

Copied in the following for a custom filter and it worked fine. Maybe a problem with parsing multiword keys?

return function (arr, field) {
          var o = {}, i, l = arr.length, r = [];
          for(i=0; i<l;i+=1) {
            o[arr[i][field]] = arr[i];
          }
          for(i in o) {
            r.push(o[i]);
          }
          return r;

kanethal avatar Feb 19 '16 08:02 kanethal

perfect to me thanks kanethal . I create new filter and use your code. Work fine!

raphitz avatar Oct 06 '16 21:10 raphitz