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

fix($parse): assign returns the new value #12708

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ ASTCompiler.prototype = {
this.state.computing = 'assign';
var result = this.nextId();
this.recurse(assignable, result);
this.return_(result);
extra = 'fn.assign=' + this.generateFunction('assign', 's,v,l');
}
var toWatch = getInputs(ast.body);
Expand Down
8 changes: 8 additions & 0 deletions test/ng/parseSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,14 @@ describe('parser', function() {
expect(scope).toEqual({a:123});
}));

it('should return the assigned value', inject(function($parse) {
var fn = $parse('a');
var scope = {};
expect(fn.assign(scope, 123)).toBe(123);
var someObject = {};
expect(fn.assign(scope, someObject)).toBe(someObject);
}));

it('should expose working assignment function for expressions ending with brackets', inject(function($parse) {
var fn = $parse('a.b["c"]');
expect(fn.assign).toBeTruthy();
Expand Down