我无法让指令 i angular 绑定到 mouseenter,我尝试了一个简单的示例,这里有什么问题?
<html lang="en" >
<head>
<title>My AngularJS test</title>
<script src="angular.js"></script>
</head>
<body >
<div ng-app="testApp" ng-controller="testCtr">
<div testDir>test here</div>
<!-- just testing to see if the app is working -->
{{test}}
<script type="text/javascript">
var app = angular.module("testApp", []);
app.directive("testDir", function(){
return {
link: function(scope, element, attrs){
element.bind("mouseenter", function(){
console.log("enter")
})
}
}
})
app.controller("testCtr", function($scope) {
$scope.test = 500;
})
</script>
</div>
</body>
</html>
这可能是一个愚蠢的错误,但我看不到它。