-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Idea $this in directive locals calls #13247
Comments
Can you give a more complete example? I've a hard time figuring out the use case. |
The problem when passing just locals to the context is that there is no way to inspect all locals at once.
That helps a lot when using debugging/using light documented directives. |
I think I see what you mean. You want to have access to a single property on the scope that references the var someExpressionFn = $parse('someExpression');
someExpressionFn($scope, locals); You would like us to automatically attach an additional property to the |
Exactly sir! Sorry if I wasn't clear before... |
I see this as a rare requirement that can be easily implemented on a case by case basis as you show in your example @jpolo. I don't think it is something that we would want to add to all cases, especially as we would have to pollute the scope with yet another special property. |
In general, if I have a load of things that I want to pass via locals that can be handled as a single thing by the client then I would set it up so: $scope.ngCallback({ $event: ctx }); This (interestingly) is similar to the form that seems to be appearing in Angular 2 event handling. |
In my user need, I am the developer that uses a third party directive |
Sure, but the third party should document their directive, no? |
Just to be clear, here is a plnkr: http://plnkr.co/edit/Hm0nWaybsJ8PxKsVQzIl?p=preview |
What you are saying is that there is no programmatic way of enumerating the |
I wonder if what we should say is that inside such an expression the |
You're right everybody should document. But sometimes it is not the case or if there is an error between doc and code. |
@petebacondarwin I do not like the idea to merge scope and local when running an expression and it would have performance implications and there would be no way to actually forcing something to be loaded from the scope (as locals has priority when
Anyhow, I find these breaking changes to be small and the benefits reasonable |
Extends the built-in identifiers definitions by adding `$local`. This is a non-assignable reference to the locals object. Closes: angular#13247
Extends the built-in identifiers definitions by adding `$local`. This is a non-assignable reference to the locals object. Closes: angular#13247
Extends the built-in identifiers definitions by adding `$local`. This is a non-assignable reference to the locals object. Closes: angular#13247
@lgalfaso can we make sure that the breaking change description in this PR gets into the changelog as it didn't make it into the commit. |
After reading this thread, the migration guide, and several SO posts, I still have no clue what
What is "locals from an expression"? What expression is this referring to?
What is I'm using Angular 1.5.3 and everywhere I've tried to reference "$locals" or "locals", it NEVER exists. Can someone offer an alternate explanation of this...thing called |
When you evaluate an expression on a scope, you can add in an additional object containing "locals", which are merged into the context (i.e. the scope) for the evaluation of that expression.
This PR should also add the
|
It would be nice to have a normalized reference to the locals for directive expression.
I've proposed $this but other candidates could be better ($locals, etc...)
Example
Allows to easily dump available locals
The text was updated successfully, but these errors were encountered: