`$eval` assignment expression and locals
We can't use a local variable in the left side of an assignment without enclosing it in parenthesis to ensure it to be resolved first.
I tried to raise a discussion here in order to understand whether it's a bug or not but had not much success.
Basically, this test case won't succeed:
it('should allow passing object as locals to the left part of an assignment expression', inject(function($rootScope) {
var ob = {};
$rootScope.scopedValue = 1;
$rootScope.$eval('a.value = scopedValue', {a: ob});
expect(ob.value).toBe(1);
expect($rootScope.a).toBeUndefined();
}));
While changing the expression to (a).value = scopedValue the test will succeed. Assembled a Plnkr here to illustrate it.
As I said before, I'm not sure if this is a bug or a limitation. If it's the later, then I think I could change the documentation to exemplify it. So, is this a bug or a expected limitation?
looks like a legit bug to me. it still repro's in 1.2.7 (http://plnkr.co/edit/2etyqSnPdzxvWEwrusqY?p=preview)
at first glance, I suspect that the problem is that we don't consider locals when doing assignment. the fix should be relatively straightforward.
check out this lines and notice how we don't consider locals during assignment but we do consider them in the getter: https://github.com/angular/angular.js/blob/e0ce9ed36d9b8c1858e4f928b61d21d7d4c023b8/src/ng/parse.js#L314-L321
would you like to send a PR (please include test)
PS: sorry for the delay and thanks for being patient
This was fixed as part of #10592