kittu
kittu

Reputation: 7008

Error using click event in javascript

I have my function call like this in HTML:

<a href="" ng-click="registerCallbacks(event)" class="btn btn-primary btn-block">Angular Call back</a> 

And I am trying to pass a event and print it out but I am getting an error:

Failed to execute 'dispatchEvent' on 'EventTarget': The event provided is null.

//Call back events
    $scope.registerCallbacks = function (event) {
        console.log("registerCallbacks not working");
        console.log(event);
        window.dispatchEvent(event);
    };

Upvotes: 2

Views: 60

Answers (1)

Robin
Robin

Reputation: 116

In your HTML you need to pass $event (you're missing the $ at the front) like so:

<a href="" ng-click="registerCallbacks($event)" class="btn btn-primary btn-block">Angular Call back</a>

Upvotes: 4

Related Questions