angularjs绑定在mouseenter指令不起作用

Øyv*_*ind 1 html javascript angularjs

我无法得到directiv i angular to bind on 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>
Run Code Online (Sandbox Code Playgroud)

这可能是一个愚蠢的错误,但我看不到它.

Jos*_*ber 5

你的属性应该是蛇形的:

<div test-dir>test here</div>
<!--     ^^               -->
Run Code Online (Sandbox Code Playgroud)

这是一个演示:http://plnkr.co/edit/bobVjZHSJ313ZLoXyKfB?p = preview