Skip to content

Instantly share code, notes, and snippets.

@ysyun
Created April 14, 2013 10:20
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 ysyun/5382217 to your computer and use it in GitHub Desktop.
Save ysyun/5382217 to your computer and use it in GitHub Desktop.
AngularJS Directive Sample Directive to Controller Communication
/*<div ng-app="twitterApp">
<div ng-controller="AppCtrl">
<div enter="loadMoreTweets()">Roll over to load more twitt</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