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:
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user