Created
November 4, 2010 02:54
-
-
Save mhevery/662069 to your computer and use it in GitHub Desktop.
Hover in angular
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
<!DOCTYPE html> | |
<html xmlns:ng="http://angularjs.org"> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript" ></script> | |
<script src="http://code.angularjs.org/angular-0.9.2.js" type="text/javascript" ng:autobind></script> | |
<script type="text/javascript"> | |
function MyController(){ | |
this.list_o_lists = [ ['e1', 'e2' ] , ['e3','e4','e5'] ]; | |
this.$watch('$location.hashPath', this.userChange); | |
} | |
MyController.prototype = { | |
userChange: function(){ | |
}, | |
hover: function(elem){ | |
alert(elem); | |
} | |
} | |
angular.directive('my:hover', function(expr){ | |
return function (element) { | |
var scope = this; | |
console.log(expr); | |
element.hover(function(){ | |
scope.$tryEval(expr); | |
}) | |
}; | |
}); | |
</script> | |
</head> | |
<body ng:init="$window.$root=this" ng:controller="MyController"> | |
<div class="alist" ng:repeat="alist in list_o_lists"> | |
<div class='elem' style="border: 1px solid green;" ng:repeat="elem in alist" my:hover="hover(elem)"> | |
{{elem}} | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment