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

fix(compile): Interpolate @ locals before the link function runs #1555

Closed

Conversation

petebacondarwin
Copy link
Contributor

Do a one-off interpolation of @ locals to ensure that the link fn receives attributes that are already interpolated.

(Rebased and reworded the commit message to make it easier to merge!)

@petebacondarwin
Copy link
Contributor Author

This is a rebased version of #1488

@petebacondarwin
Copy link
Contributor Author

Also, the addAttrInterpolateDirective should also initialize the value of an interpolated attribute to ensure that it is available to link functions of custom directives.

@petebacondarwin
Copy link
Contributor Author

Thread on the mailing relating to this: https://groups.google.com/d/topic/angular/Np7WX0_3aYA/discussion

Do a one-off interpolation of @ locals to ensure that the link fn receives attributes that are already interpolated.
@pkozlowski-opensource
Copy link
Member

A bug report related to this one: #1752 (I'm sure that there are more).

@pkozlowski-opensource
Copy link
Member

Current behavior seems to be really a bit confusing for people: http://stackoverflow.com/q/14552024/1418796

@petebacondarwin
Copy link
Contributor Author

Not much we can do, since we really do have to wait for the first digest to
complete to get a genuine value for any interpolated value. My fix only
works for @ values and not for other {{}} interpolated attributes. Also it
does not exception handling in the case that someone sticks something
dangerous into an interpolation, e.g. {{ 1 / 0 }} or {{
infinitelyRecursiveFn() }}

On 27 January 2013 20:58, Pawel Kozlowski notifications@github.com wrote:

Current behavior seems to be really a bit confusing for people:
http://stackoverflow.com/q/14552024/1418796


Reply to this email directly or view it on GitHubhttps://github.com//pull/1555#issuecomment-12761435.

@mhevery
Copy link
Contributor

mhevery commented Feb 14, 2013

MERGED

@mhevery mhevery closed this Feb 14, 2013
@petebacondarwin
Copy link
Contributor Author

@mhevery - I thought you decided this was bad juju?

@petebacondarwin petebacondarwin deleted the local-attr-interpolation branch February 15, 2013 08:47
@IgorMinar
Copy link
Contributor

we looked at it again and decided that the harm caused by not merging this is bigger than the confusion that is caused by the issue being fixed.

@ideaocean
Copy link

was it actually fixed? I am still having the same issue with the latest angular..

@petebacondarwin
Copy link
Contributor Author

I think not. Just remember to either $observe the attribute or to manually
$eval it in the link function

On 18 July 2013 01:03, ideaocean notifications@github.com wrote:

was it actually fixed? I am still having the same issue with the latest
angular..


Reply to this email directly or view it on GitHubhttps://github.com//pull/1555#issuecomment-21154473
.

@cagataycivici
Copy link

It seems to be fixed with 1.1.5, e.g for locals myattr="Test" and for bindings myattr={{controllerPropertyHere}} work. However attr="controllerPropertyHere" doesn't work though which is not a major drawback problem. Without this fix, we had to deal with watch expressions and so on which are confusing and complicated compared to this approach.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants