user3111525
user3111525

Reputation: 5203

How to use ngMousedown correctly?

I am trying to catch the ngMousedown event but can't get it to work. Spent some time on searching for solution on the Web, no luck.

Here is the jsfiddle snippet. I also tried mouseup and click. Obviously, something trivial I am missing

<html ng-app>
  <head>
    <script src="http://code.angularjs.org/1.2.0-rc.2/angular.min.js"></script>
    <script src="script.js"></script>
  </head>
  <body>
    <div ng-controller="HelloCntl">
      <hr/>
        <div style="border:1px solid red;" ng-mousedown="alert('x');">
            ng-mousedown
        </div>
    </div>
  </body>
</html>

Upvotes: 3

Views: 4955

Answers (1)

Zack Argyle
Zack Argyle

Reputation: 8407

Here is a working fiddle. The issue was that alert('x') was looking for $scope.alert as a function in your controller.

Ng-Mousedown Fiddle

$scope.alert = function(x) {
    alert(x);
}

Upvotes: 2

Related Questions