Created
March 2, 2014 22:33
-
-
Save pfallasro/9315006 to your computer and use it in GitHub Desktop.
AngularJS directives talking to controllers
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 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