I want to run some function on load of a directive, and then be able to "rerun" it again with ng-click
. My code is as follows:
const app = angular.module('app', []);
class dummyController {
logIt() {
console.log('logging');
}
}
app.directive('dummyDir', () => {
return {
controller: dummyController,
link(scope, element, attrs, ctrl) {
scope.logIt = ctrl.logIt();
scope.logIt;
}
};
});
HTML
<div ng-app="app">
<button class="reinit" type="submit" dummy-dir ng-click="logIt()">Reinit</button>
</div>
Unfortunately, clicking the button does nothing. What have I done wrong?