I have the following problem. I would like to call controller function from a directive with isolated scope.
HTML:
<div ng-controller="MainController">
<test></test>
</div>
JS:
var app = angular.module("app", []);
app.controller("MainController", function ($scope) {
$scope.testFunction = function () {
console.log("You just call testFunction()!");
};
});
app.directive("test", function () {
return {
restrict: "E",
scope: {},
template: "<h1 ng-click='testFunction()'>Hello world!</h1>"
};
});
When directive don't have an isolated scope, the call function follows.