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

$eval assignment expression and locals #4664

Closed
@caiotoon

Description

@caiotoon

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions