AngularJS How to call directive function from controller
<p>I was looking for a way to find out how to call a function inside a directive from the controller. I got the snip but hence I am new to Angular, the below code flow is not very clear. Anyone mind to explain how the code is working. Thanks.</p>
<pre><code>// Directive 
&lt;map set-fn=&quot;setDirectiveFn(theDirFn)&quot;&gt;&lt;/map&gt;

scope: { setFn: '&amp;' },
link: function(scope, element, attrs) {
    scope.updateMap = function() {
       alert('inside updateMap()');
    }
    scope.setFn({theDirFn: scope.updateMap});
}

// Controller
&lt;button ng-click=&quot;directiveFn()&quot;&gt;call directive function&lt;/button&gt;
function MyCtrl($scope) {
    $scope.setDirectiveFn = function(directiveFn) {
        $scope.directiveFn = directiveFn;
    };
}
</code></pre>