Here is a sample controller and directive code:
class DashboardCtrl {
constructor ($scope, $stateParams) {
"ngInject";
this.$scope = $scope;
this.title = 'Dashboard';
}
loadCharts () {
// some logic here
}
}
export default DashboardCtrl;
Now let's take a look at the directive:
class TreeNodeTooltip {
constructor ($scope, $state) {
"ngInject";
this.$scope = $scope;
this.$state = $state;
this.scope = {
loadCharts: '&'
};
}
link (scope, elem, attrs) {
$(elem).on('click', '.node-name', (e) => {
console.log(this.$scope.loadCharts());
console.log(this.scope.loadCharts());
console.log(this.$scope.main.loadCharts());
}
}
}
Having trouble accessing the controller function from the directive? Any suggestions on how to make it work?