I have an Angular directive that creates an accordion out of <ol>
and <li>
elements, with each <li>
's content being wrapped in a transcluded template. I need to fire a method to check if any of these <li>
elements has an error, and open that accordion, but I can't find a way to fire the method after the elements have been transcluded.
Is there a hook or directive config that will time this correctly?
I suppose you can access content in postLink
function defined in directive definition object. Check official documentation.
Directive definition object enables you to define:
compile: function compile(tElement, tAttrs, transclude) {
return {
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
post: function postLink(scope, iElement, iAttrs, controller) { ... }
}
// or
// return function postLink( ... ) { ... }
},
and there you can inject and access iElement and its content. This happens after template compilation so <li>
elements should be already in place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With