After researching online, it appears that there are numerous questions similar to mine but unfortunately, none of the solutions provided worked for me.
In my current situation, I have a directive which includes a function like this (within the directive):
link: function(scope, element, attrs) {
scope.myfunction = function (){
console.log('function run');
};
}
I want to be able to call this function from a controller using a simple command like this:
$scope.myFunction();
This way, I can easily access and execute the function from a part of my page outside of the directive code, perhaps by adding a button like this:
<button ng-click="myFunction()">Run</button>
My question is, is it possible to achieve this functionality?