yodalr
yodalr

Reputation: 10902

AngularJS: detecting mouse left click?

I tried this modified version of jquery function:

$scope.link_clicked = function(e) {
    if (e.button == 0) {
        $("#spinner_bg").css("display", "block");
    }
};

But it gives error: "Cannot read property 'button' of undefined..." :/

Upvotes: 0

Views: 1361

Answers (1)

Joy
Joy

Reputation: 9550

You need to pass in the $event object: ng-click=link_clicked($event) like JSFiddle.

The JS code:

angular.module('Joy', [])
.controller('JoyCtrl', ['$scope', function ($scope) {
    $scope.link_clicked  = function (e) {
        console.log(e);
    };
}]);

Upvotes: 1

Related Questions