Saturday, 17 August 2013

AngularJS directive and string interpolation

AngularJS directive and string interpolation

Context:
I'm applying a Lightbox effect on some DOM elements using an AngularJS
directive named opensAsPopup.
Issue:
Some of these elements have dynamical content coming from a ng-repeat
directive, and it seems that my opensAsPopup directive applies before the
string interpolation.
Would that be possible to apply the lightbox effect after the string
interpolation?



HTML:
<li>
<a href="/path/to/{{entry.id}}" opens-as-popup>Link</a>
</li>
Script:
app.directive("opensAsPopup", [ ->
restrict: "A"
scope: {}
replace: false
transclude: false
compile: (tElement, tAttrs) ->
new lightbox(tElement.get(0))
])

No comments:

Post a Comment