I have a directive setup as follows:
angular.module("app", []).directive("myDirective", function(){
return {
scope: {},
link: function($scope){
$scope.myFunction = function(){
//Do DOM manipulation
}
}
}
});
and in my html I simply have
<div my-directive>
<a href="" ng-click="myFunction()">Click Me</a>
</div>
when I click "Click Me" nothing prints to the console, HOWEVER, if I remove the scope property or change it to scope:true then it works as expected. I know this has to do with isolate scope but I don't fully understand what's going on. I want to have an isolate scope as this is going to be a modular directive I will use in many different project.
NOTE: I'm using angular 1.4.6
UPDATE: This function needs to do DOM manipulation. Which is why it's in the link function.