Skip to content

Instantly share code, notes, and snippets.

@pfallasro
Created March 2, 2014 22:33
Show Gist options
  • Save pfallasro/9315006 to your computer and use it in GitHub Desktop.
Save pfallasro/9315006 to your computer and use it in GitHub Desktop.
AngularJS directives talking to controllers
var myApp = angular.module('behaviorApp', []);
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 () {
//The $apply the function name received in the attrs.enter and execute it
scope.$apply(attrs.enter)
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment