So lets say I have a directive that looks like so:
(function () {
'use strict';
angular
.module('app')
.directive('foo', foo);
/* @ngInject */
function foo() {
var directive = {
restrict : 'E',
controller: controller,
controllerAs: 'vm',
link: link,
transclude : true,
replace : true,
bindToController: true,
scope: {},
template : '<div><div ng-transclude></div>'
};
return directive;
function controller() {
var vm = this;
vm.click = function () {
// do something, add class whatever
}
}
function link(scope, elem, attrs) {}
}
}());
Now if I use the directive like so:
<foo>
<button ng-click="vm.click()">Click me!</button>
</foo>
I wanted to access the click function of the directive, how do I do that?