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

Commit

Permalink
fix($parse): allow arguments to contain filter chains
Browse files Browse the repository at this point in the history
Thanks to @esarbanis for the original PR that got out-dated due to the
big $parse overhaul.

Closes #4175
Closes #4168
Closes #14720
  • Loading branch information
petebacondarwin committed Jun 6, 2016
1 parent 294d679 commit cc6dcb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ AST.prototype = {
var args = [];
if (this.peekToken().text !== ')') {
do {
args.push(this.expression());
args.push(this.filterChain());
} while (this.expect(','));
}
return args;
Expand Down
9 changes: 9 additions & 0 deletions test/ng/parseSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,15 @@ describe('parser', function() {
expect(scope.$eval("add(1,2)")).toEqual(3);
});

it('should allow filter chains as arguments', function() {
scope.concat = function(a, b) {
return a + b;
};
scope.begin = 1;
scope.limit = 2;
expect(scope.$eval("concat('abcd'|limitTo:limit:begin,'abcd'|limitTo:2:1|uppercase)")).toEqual("bcBC");
});

it('should evaluate function call from a return value', function() {
scope.getter = function() { return function() { return 33; }; };
expect(scope.$eval("getter()()")).toBe(33);
Expand Down

0 comments on commit cc6dcb4

Please sign in to comment.