Skip to content

Instantly share code, notes, and snippets.

@abruzzi
Last active January 1, 2016 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abruzzi/8122830 to your computer and use it in GitHub Desktop.
Save abruzzi/8122830 to your computer and use it in GitHub Desktop.
directive invoke controller methods
<div ng-app="twitterApp">
<div ng-controller="AppCtrl">
<div enter="deleteTweets()">Roll over to load more tweets</div>
</div>
</div>
var app = angular.module("twitterApp", []);
app.controller("AppCtrl", function($scope) {
$scope.loadMoreTweets = function() {
alert("Loading tweets!");
}
$scope.deleteTweets = function() {
alert("deleting tweets");
}
});
app.directive("enter", function() {
return function(scope, element, attrs) {
element.bind("mouseenter", function() {
scope.$apply(attrs.enter)
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment