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

Commit cc6dcb4

Browse files
fix($parse): allow arguments to contain filter chains
Thanks to @esarbanis for the original PR that got out-dated due to the big $parse overhaul. Closes #4175 Closes #4168 Closes #14720
1 parent 294d679 commit cc6dcb4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/ng/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ AST.prototype = {
545545
var args = [];
546546
if (this.peekToken().text !== ')') {
547547
do {
548-
args.push(this.expression());
548+
args.push(this.filterChain());
549549
} while (this.expect(','));
550550
}
551551
return args;

test/ng/parseSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,15 @@ describe('parser', function() {
21382138
expect(scope.$eval("add(1,2)")).toEqual(3);
21392139
});
21402140

2141+
it('should allow filter chains as arguments', function() {
2142+
scope.concat = function(a, b) {
2143+
return a + b;
2144+
};
2145+
scope.begin = 1;
2146+
scope.limit = 2;
2147+
expect(scope.$eval("concat('abcd'|limitTo:limit:begin,'abcd'|limitTo:2:1|uppercase)")).toEqual("bcBC");
2148+
});
2149+
21412150
it('should evaluate function call from a return value', function() {
21422151
scope.getter = function() { return function() { return 33; }; };
21432152
expect(scope.$eval("getter()()")).toBe(33);

0 commit comments

Comments
 (0)