jQuery
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
$('.box').bind('mousedown', function(){
alert('box class clicked');
});
angular
<div ng-app="myApp" >
<div data-ng-controller="myCtrl">
<div ng-click="boxClick()" class="box"></div>
<div ng-click="boxClick()" class="box"></div>
<div ng-click="boxClick()" class="box"></div>
</div>
</div>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.boxClick = function(){
alert('box class clicked');
}
});
Now I am learning AngularJS, if we see this, short and crispy will be jQuery, for a single click event we are writing these much of line code in AngularJS, can anyone help me to write short as much as jQuery, how to select DOM element in AngularJS like jQuery, I am using ng-click
to trigger click event in AngularJS, without that can I able to trigger click event in script tag itself. Thanks for replies in advance