Tuesday, January 30, 2018

How to write a program for object event in angularJS.

You can pass the $event object as an argument when calling the function.
The $event object contains the browser's event object.

Program
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
</script>
</head>
<body>
<div ng-app="myapp" ng-controller="myctrl">
<h1 ng-mousemove="myFunc($event)">
Mouse Over Me
</h1>
<p>
coordinates:{{x + ',' + y}}
</p>
       </div>
<script>
var app=angular.module("myapp",[]);
app.controller("myctrl",function($scope)
{
$scope.myFunc=function(obj)
{
$scope.x=obj.clientX;
$scope.y=obj.clientY;
}
});
</script>
</body>
</html>

Output





0 comments:

Post a Comment

Thanks For Commented.

TechTalk