Created
April 14, 2013 10:20
-
-
Save ysyun/5382217 to your computer and use it in GitHub Desktop.
AngularJS Directive Sample
Directive to Controller Communication
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="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