From 43026cea6c7689f7ca1b1398deab06bb8aa513a7 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Mon, 6 Jun 2016 14:29:34 +0100 Subject: [PATCH] fix($parse): allow arguments to contain filter chains Closes #4175 Closes #4168 --- src/ng/parse.js | 2 +- test/ng/parseSpec.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ng/parse.js b/src/ng/parse.js index 99c023cb919d..3599b7f25947 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -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; diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index c823b3a9e938..116bd9f06de2 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -2139,6 +2139,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);