i've created a directive and i'm not quite sure about the binding like element.bind("click", function(){}). The link function of each directive gets called multiple times and each call will produce a duplicate binding. What is the most Angular way to accomplish this (even the click binding is available as attribute) ?
var globalCounter = 0;
app.directive("myDirective", function()
{
return {
link: function(scope, element) {
globalCounter++;
$(element).bind("click", function () {});
}
}
});
The globalCounter variable (and the click bindings ?) will increase every time i change the ng-view to a different template.
Maybe the element gets destroyed and the binding with it, i'm not sure, maybe this is my answer.