Toggle class with ng-click on several elements

I made simple directive for testing: module.directive(‘toggleClass’, function() { return { restrict: ‘A’, link: function(scope, element, attrs) { element.bind(‘click’, function() { element.toggleClass(attrs.toggleClass); }); } }; }); so you can make any element toggle class you need <button id=”btn” toggle-class=”active”>Change Class</button> <div toggle-class=”whatever”></div>

Handling ng-click and ng-dblclick on the same element with AngularJS

You could just write your own. I took a look at how angular handled click and modified it with code I found here: Jquery bind double click and single click separately <div sglclick=”singleClick()” ng-dblClick=”doubleClick()” style=”height:200px;width:200px;background-color:black”> mainMod.controller(‘AppCntrl’, [‘$scope’, function ($scope) { $scope.singleClick = function() { alert(‘Single Click’); } $scope.doubleClick = function() { alert(‘Double Click’); } }]) … Read more

AngularJS – multiple ng-click – event bubbling

This solution worked for me (I’m only supporting recent browsers, so I tried to modify the code to be more retro-compatible): HTML: <li ng-repeat=”item in items” ng-click=”showItem(item)”> <h3>{{item.title}}</h3> <button ng-click=”remove(item, $event)”>Remove</button> </li> Scripts: function remove(item, $event) { // do some code here // Prevent bubbling to showItem. // On recent browsers, only $event.stopPropagation() is needed … Read more

Pass a reference to DOM object with ng-click

While you do the following, technically speaking: <button ng-click=”doSomething($event)”></button> // In controller: $scope.doSomething = function($event) { //reference to the button that triggered the function: $event.target }; This is probably something you don’t want to do as AngularJS philosophy is to focus on model manipulation and let AngularJS do the rendering (based on hints from the … Read more

Automatically pass $event with ng-click?

Take a peek at the ng-click directive source: … compile: function($element, attr) { var fn = $parse(attr[directiveName]); return function(scope, element, attr) { element.on(lowercase(name), function(event) { scope.$apply(function() { fn(scope, {$event:event}); }); }); }; } It shows how the event object is being passed on to the ng-click expression, using $event as a name of the parameter. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)