Last active
January 1, 2016 09:09
-
-
Save abruzzi/8122830 to your computer and use it in GitHub Desktop.
directive invoke controller methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="twitterApp"> | |
<div ng-controller="AppCtrl"> | |
<div enter="deleteTweets()">Roll over to load more tweets</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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