Whats best practice to use for click handling in my own directives?


#1

ive written my own directive that changes content based on a service:

whenever the service is changed via controllers it rootScope broadcasts a msg that my directive will listen for in the link function, the elements content is now filled with data from the service with element.html(contentstuff)

setting ng-click here directly doesnt work (because angular doesnt know about this), i tried using $compile(element)(scope) which didnt kill click handlers and every time the directive changed content they stacked (and it used the wrong data, different problem i guess)

so i thought id use jqlites .on(“click”, … instead

are there any problems using this with ionic (like not removing 300ms delay) or is there a better best practice way to populate the directives element (element.html seems kinda wrong)


#2

I’d need a better sense of your code, like some sample code, to understand better what your directive is doing. Directives should be able to work with ngClick, so I suspect there may be an issue with how you’ve designed the directive.