angularjs - Creating single custom directive for ng-click to perform multiple controller function -


i have following code:

<div>...      <div class="glyphicon glyphicon-filter ng-click="vm.add()" tabindex="1">      <a href='' tabindex="2"><img id="touch" ng-click="vm.multiply(xyz)"       src="/ui/assets/images/xxx.png"/></a>       <div class="glyphicon glyphicon-filter"ng-click="vm.showid()" tabindex="1" title="filter">      </div>  ..</div>  

i want create custom single ng-click directive recommended div (ng-click used buttons). want know if there way can create single directive 3 ng-click , call 3 different functions in link @ $apply?

here go: http://jsfiddle.net/psevypcs/2/

html

<div clicky="test()">test</div> <div clicky="test2()">test2</div> 

angularjs-controller

$scope.test = function(){        alert('hy');    };   $scope.test2 = function(){        alert('hy2');    }; 

angularjs-directive

angular.module('myapp')         .directive('clicky', clicky);      function clicky() {         return {             restrict: 'a',             scope: {                 clicky: '&'  // take variable             },             link: function(scope, element, attrs){                $(element).on('click', function(e) {                   scope.clicky();                });             }       };     } 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -