Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Exception is thrown when special characters are used in OrderBy filter #6143

Closed
MaxShv opened this issue Feb 6, 2014 · 5 comments
Closed

Comments

@MaxShv
Copy link

MaxShv commented Feb 6, 2014

I am getting the below exception when a special character, such as '%', is used in the OrderBy filter to sort the object by the key. Can you please suggest a work around for this issue? Thanks!
http://plnkr.co/edit/hNYeujXNcG4HaJc9c3Td?p=preview

Error: [$parse:syntax] http://errors.angularjs.org/1.2.11/$parse/syntax?  p0=undefined&p1=not%20a%20primary%20expression&p2=null&p3=Chg%20%25&p4=Chg%20%25
at Error (native)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:6:450
at Ya.throwError (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:155:346)
at Ya.primary (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:155:30)
at Ya.unary (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:161:240)
at Ya.multiplicative (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:161:39)
at Ya.additive (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:160:340)
at Ya.relational (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:160:204)
at Ya.equality (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:160:66)
at Ya.logicalAND (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.min.js:159:456) 
@caitp
Copy link
Contributor

caitp commented Feb 6, 2014

This seems like a bug in the orderBy filter. I think I can fix this pretty easily

caitp added a commit to caitp/angular.js that referenced this issue Feb 6, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

Closes angular#6143
@caitp
Copy link
Contributor

caitp commented Feb 6, 2014

Well there's a fix for ya, lets see if it gets R+'d

caitp added a commit to caitp/angular.js that referenced this issue Feb 6, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

Closes angular#6143
@IgorMinar
Copy link
Contributor

@caitp you forgot to label this properly and assign it to a milestone

@caitp caitp added this to the 1.2.12 milestone Feb 6, 2014
@caitp caitp self-assigned this Feb 6, 2014
@caitp
Copy link
Contributor

caitp commented Feb 6, 2014

done-ish

caitp added a commit to caitp/angular.js that referenced this issue Feb 6, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes angular#6143
caitp added a commit to caitp/angular.js that referenced this issue Feb 6, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes angular#6143
@MaxShv
Copy link
Author

MaxShv commented Feb 6, 2014

Thank you!

caitp added a commit to caitp/angular.js that referenced this issue Feb 6, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes angular#6143
@tbosch tbosch modified the milestones: 1.2.13, 1.2.12 Feb 7, 2014
@btford btford modified the milestones: 1.2.14, 1.2.13 Feb 15, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-beta.1, 1.2.14 Mar 1, 2014
@btford btford modified the milestones: 1.3.0-beta.2, 1.3.0-beta.1 Mar 10, 2014
@tbosch tbosch modified the milestones: 1.3.0-beta.3, 1.3.0-beta.2 Mar 14, 2014
caitp added a commit to caitp/angular.js that referenced this issue Mar 19, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes angular#6143
caitp added a commit to caitp/angular.js that referenced this issue Mar 19, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes angular#6143
@caitp caitp closed this as completed in 37bc5ef Mar 19, 2014
caitp added a commit that referenced this issue Mar 21, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes #6143
Closes #6144
tbosch pushed a commit to tbosch/angular.js that referenced this issue Mar 21, 2014
The orderBy filter now allows string predicates passed to the orderBy filter to make use property
name predicates containing non-ident strings, such as spaces or percent signs, or non-latin
characters.

This behaviour requires the predicate string to be double-quoted.

In markup, this might look like so:

```html
<div ng-repeat="item in items | orderBy:'\"Tip %\"'">
...
</div>
```

Or in JS:

```js
var sorted = $filter('orderBy')(array, ['"Tip %"', '-"Subtotal $"'], false);
```

Closes angular#6143
Closes angular#6144
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants