angularjs - Directive listening for click event with 3 paramaters -


i have directive listening click event , picking parameter values 3 values showing in debugger param 1's value, param 2 & 3 being undefined.

html:

<div my-directive data-ng-click="(vm.id, vm.title, vm.name)"></div> 

directive:

.directive('mydirective', ['config', function (config) {     // ...     link: function (scope, elem, attrs) {       // ...       // click event       elem.bind('click', function () {         attrs.$observe('onclick', function (param1, param2, param3) {         // ... 

how should ng-click parameter values in html written values picked individually directive?

html:

 <div my-directive data-ng-click="clickme();"            data-param1="samplea" data-param2="sampleb" data-param3="samplec"> </div> 

directive:

 .directive('mydirective', ['config', function (config) {        ..............          link: function (scope, elem, attrs) {             ..................             // click event             elem.bind('click', function () {                 attrs.$observe('onclick', function () {                ......             var result1 = attrs.param1;             var result2 = attrs.param2;             var result3 = attrs.param3;               .....             if (result1 != undefined && result2 != undefined && result3 != undefined) {                 switch (result1) {                  case "samplea":                   // call parent controller on directive's html page                    scope.vm.myctrl1function(result1, result2, result3);                    break;                        .................                   }               };           });       }]); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -