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
This commit is contained in:
Peter Bacon Darwin
2016-06-06 14:29:34 +01:00
parent b9ac3362ee
commit 362d11b519
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -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;
+9
View File
@@ -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);