2

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);
    };

1 Answer 1

4

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>
Sign up to request clarification or add additional context in comments.

2 Comments

Is it because of angular? normally in plain javascript we pass only event right?
@kittu yup, just an angular thing! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.