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

ngRepeat 'AS' can't be placed on controllerAs variable. #8438

Closed
joshbowdoin opened this issue Jul 31, 2014 · 0 comments
Closed

ngRepeat 'AS' can't be placed on controllerAs variable. #8438

joshbowdoin opened this issue Jul 31, 2014 · 0 comments

Comments

@joshbowdoin
Copy link
Contributor

I would like to be able to place the new ngRepeat 'AS' object on my controllerAs variable.

That way, I could either write item in items | filter:x as results or item in items | filter:x as myCtrl.results

Plunk demonstrating that this isn't currently possible:
http://plnkr.co/edit/295zNjJ6wLlKtYTXL9wA?p=preview

I really like the controllerAs syntax, and like knowing for sure which scope a variable is defined on. It seems like a step backwards to not be able to do so.

caitp added a commit to caitp/angular.js that referenced this issue Aug 1, 2014
Parse aliasAs as an expression, and assert that the expression is assignable.

BREAKING CHANGE

Previously, any name passed as an expression would make up a single property name, including constant
values such as 1, NaN, null, undefined, or even expressions such as function calls or boolean expressions.

Now, more complex expressions are possible, allowing the collection alias to be assigned as a property
of an object --- however, if the expression is not determined to be assignable, it will throw.

Fixes angular#8438
@caitp caitp added this to the Backlog milestone Aug 1, 2014
@caitp caitp self-assigned this Aug 1, 2014
caitp added a commit to caitp/angular.js that referenced this issue Aug 1, 2014
Parse aliasAs as an expression, and assert that the expression is assignable.

BREAKING CHANGE

Previously, any name passed as an expression would make up a single property name, including constant
values such as 1, NaN, null, undefined, or even expressions such as function calls or boolean expressions.

Now, more complex expressions are possible, allowing the collection alias to be assigned as a property
of an object --- however, if the expression is not determined to be assignable, it will throw.

Fixes angular#8438
caitp added a commit to caitp/angular.js that referenced this issue Aug 1, 2014
Parse aliasAs as an expression, and assert that the expression is assignable.

BREAKING CHANGE

Previously, any name passed as an expression would make up a single property name, including constant
values such as 1, NaN, null, undefined, or even expressions such as function calls or boolean expressions.

Now, more complex expressions are possible, allowing the collection alias to be assigned as a property
of an object --- however, if the expression is not determined to be assignable, it will throw.

Fixes angular#8438
caitp added a commit to caitp/angular.js that referenced this issue Aug 1, 2014
Parse aliasAs as an expression, and assert that the expression is assignable.

BREAKING CHANGE

Previously, any name passed as an expression would make up a single property name, including constant
values such as 1, NaN, null, undefined, or even expressions such as function calls or boolean expressions.

Now, more complex expressions are possible, allowing the collection alias to be assigned as a property
of an object --- however, if the expression is not determined to be assignable, it will throw.

Fixes angular#8438
caitp added a commit to caitp/angular.js that referenced this issue Aug 20, 2014
Ensure that aliasAs expressions are valid simple identifiers. These are still assigned to $scope in the same way
that they were previously, however now you won't accidentally create a property named "filtered.collection".

This change additionally restricts identifiers to prevent the use of certain ECMAScript reserved words ("null",
"undefined", "this" --- should probably add "super", "try", "catch" and "finally" there too), as well as certain
properties used by $scope or ngRepeat, including $parent, $index, $even, $odd, $first, $middle, or $last.

Fixes angular#8438
@btford btford removed the gh: issue label Aug 20, 2014
@caitp caitp closed this as completed in 09b2987 Aug 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.