2

In this code event display undefined.

<div class="div1" ng-click="displayinfo(event)">
    sadfasf
</div>

$scope.displayinfo = function(event)
{
     alert(event);
}

can anyone help. thanks

2 Answers 2

4

Use $event instead of event. It is little hidden in the docs http://docs.angularjs.org/api/ng.directive:ngClick

Sign up to request clarification or add additional context in comments.

1 Comment

Although this is the correct answer it should be noted that injecting DOM events to controller functions is often a bad practice as most of the time any DOM manipulation logic should be kept out of controllers and moved to directives instead.
2

Very close--but it's $event.

<div class="div1" ng-click="displayinfo($event)">
    sadfasf
</div>

$scope.displayinfo = function(event)
{
     alert(event);
}

Comments

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.