Directives ========== Directive calls controller ------------------------- app.controller("AppCtrl", function($scope) { $scope.func = function() { alert("Controller's function published on scope"); } } app.directive(“enter”, function(scope, el, attr) { element.bind(“mouseenter”, function() { scope.$apply(attr.enter); } }
Put your mouse here to call controller's func from directive
Directive calls directive ------------------------- app.directive("parentDirective", function(){ return { scope: {}, //! isolates scope controller: function($scope) { $this.func1 = function(){}... }, link: function(scope, element) { element.addClass(...) element.bind("event", function(){...}) } } }); app.directive("childdirective", function() { return { require:"parentdirective", link: function(scope, element, attrs, parentCtrl){ parentCtrl.func1(...) } } } ht