ngClick
What is ngClick ?
An ngClick directive to allow a customer even handling functions. An html element make any click event logic is need to implement ng-click in DOM.
Syntax:
<input type ="anytype" ng-click="function_name()">
How to pass Current Object or Event ?
When we want get current clicked dom object properties is need means we pass $event param to corresponding method.
<input type ="anytype" ng-click="function_name($event)">
Example :
<div ng-app="appClick">
<div ng-controller="appController">
<input type="button" value="Click" ng-click="showClick()" />
<input type="button" name="buttonClick" value="click+Event" ng-click="showClickEvent($event)" />
</div>
</div>
Java Script:
var appClick = angular.module("appClick",[]);
appClick.controller("appController",['$scope', function($scope){
$scope.showClick = function() {
alert('ng-click function');
}
$scope.showClickEvent = function(obj) {
alert(obj.target);
alert(obj.target.name);
alert(obj.target.type);
alert(obj.target.value);
}
}]);
Comments
Post a Comment