Access template element from controller
jviotti opened this issue · comments
I'm looking forward to access the template element from the controller:
return btfModal({
controller: 'MyCtrl'
template: '<div class="btf-modal">Hello {{ctrl.name}}</div>'
});
controller('MyCtrl', function ($element) {
// $element should be equal to an element pointing to `.btf-modal`.
});
Is this currently possible somehow (from $element or the modal service, etc)?
There's rarely ever a good reason to expose an element to a controller. What's your use case?
I'm working in an Hybrid mobile application. The modal shows a picture that has just been taken from the camera.
We have a set of "element decorators" services that add some capabilities to a surface, eg: an annotation decorator that adds annotation support with floating notes, etc.
These decorators take an element on instantiation, however I'm not able to easily expose the modal element to the decorator.
I could do a whole query for the element but I'm looking forward for a cleaner solution.
Write a directive that uses these services. Use the directive in the modal's template.
Sounds like a good solution. Thanks for the support.