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

Angular 1.2: Using "terminal" on a directive breaks the interpolation on attrs.$observe #4525

Closed
portersi opened this issue Oct 18, 2013 · 6 comments
Assignees

Comments

@portersi
Copy link

Here's an example using Angular 1.2 RC3:
http://plnkr.co/edit/LMF2YuJW1Opj9gS3wv63?p=preview

If you open the JS console you can see what the observed value is. It's uninterpolated with its curly braces still intact.

Here's the same code running on Angular 1.0.8 that works correctly:
http://plnkr.co/edit/E0vINw7Pyjk0G2I1UwBI?p=preview

@portersi
Copy link
Author

I was playing around with priority and found that interpolation works with any priority less than -99. So with priority -100 the value is interpolated, with -99 it isn't. Not sure what's going on there...

@portersi
Copy link
Author

Must be this:

priority: -100,

@portersi
Copy link
Author

Maybe this isn't a bug? I can workaround by changing the priority, feel free to triage however you like.

@pschachner
Copy link

Having the same issue with last stable version (1.0.8). I have an expression with curly braces within ng-click directive, that makes the ng-click not to be called:

<button data-ng-click="redirectTo('employee/edit/{{employeeId}}' )">Edit</button>

@portersi
Copy link
Author

This is a different issue. Attributes are generally either evaluated or interpolated -- ng-click is evaluated, not interpolated, so curly braces aren't treated special. You can try:

ng-click="redirectTo('employee/edit/' + employeeId)"

@btford
Copy link
Contributor

btford commented Oct 23, 2013

I think this is working as intended. If you say a directive is terminal, and it has a higher priority than other directives on the same element, I would expect those directives not to be invoked by $compile. Like you said, you can specify a lower priority for your directive.

@ghost ghost assigned IgorMinar Oct 24, 2013
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
…rectives

Recently we changed the priority of attribute interpolation directive to -100
to ensure that it executes early in the post linking phase. This causes issues
with when terminal directives are placed on elements with attribute bindings
because the terminal directive will usually have 0 or higher priority which
results in attr interpolation directive not being applied to the element.

To fix this issue I'm switching the priority back to 100 and making moving the
binding setup into the pre-linking function.

This means that:

- terminal directives with priority lower than 100 will not affect the attribute
  binding
- if a directive wants to add or alter bindings it can do so in the pre-linking
  phase, as long as the priority of this directive is more than 100
- all post-linking functions will execute after the attribute binding has been
  set up
- all pre-linking functions with directive priority lower than 100 will execute
  after the attribute bindings have been setup

BREAKING CHANGE: the attribute interpolation (binding) executes as a directive
with priority 100 and the binding is set up in the pre-linking phase. It used
to be that the priority was -100 in rc.2 (100 before rc.2) and that the binding
was setup in the post-linking phase.

Closes angular#4525
Closes angular#4528
Closes angular#4649
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
…rectives

Recently we changed the priority of attribute interpolation directive to -100
to ensure that it executes early in the post linking phase. This causes issues
with when terminal directives are placed on elements with attribute bindings
because the terminal directive will usually have 0 or higher priority which
results in attr interpolation directive not being applied to the element.

To fix this issue I'm switching the priority back to 100 and making moving the
binding setup into the pre-linking function.

This means that:

- terminal directives with priority lower than 100 will not affect the attribute
  binding
- if a directive wants to add or alter bindings it can do so in the pre-linking
  phase, as long as the priority of this directive is more than 100
- all post-linking functions will execute after the attribute binding has been
  set up
- all pre-linking functions with directive priority lower than 100 will execute
  after the attribute bindings have been setup

BREAKING CHANGE: the attribute interpolation (binding) executes as a directive
with priority 100 and the binding is set up in the pre-linking phase. It used
to be that the priority was -100 in rc.2 (100 before rc.2) and that the binding
was setup in the post-linking phase.

Closes angular#4525
Closes angular#4528
Closes angular#4649
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants