javascript - unable to access scope property value in directive from a listener function of dragover event inside the link function -


i have directive "droppable" , in scope have property called "configuration" contains value of type object. being bind individual object inside ng-repeater.

i have added event listener & handler "dragover" event of element inside link function. in handler of element accessing scope.configuration should contain value have provided html template(value object inside ng-repeater).

the template have created recursive 1 dragover event bind elements , children well.

what doing these whenever drag on these elements depending upon configuration object(which array of values decide whether droppable area)user indicated setting .dropeffect=move / none.

the problem not getting scope.configuration target element of "dragover: event. please me this.

comdir.directive('droppable', function () {     return {         scope: {             "configuration": "=config",         },         link: function (scope, element, attrs) {              var el = element[0];             el.dataset.isdroppable = true;               var fndragover = function (e) {                  var targetel = e.target;                  // no action if element doesn't have droppable attribute.                 if(!targetel.hasattribute('droppable'))                     return false;                  var el_isdroppable = targetel.getattribute('droppable') === "false"? false: true;                 var indx;                 //checking if draggedoperation in alloweddrops of configuration object                 if(scope.configuration){                     indx = scope.configuration.alloweddrops.indexof(scope.$parent.draggedoperation);                 };                  if(el_isdroppable && (!scope.configuration || indx >= 0) ) {                     e.datatransfer.dropeffect = 'move';                                                  if(el_isdroppable)                         $(targetel).addclass('borderred');                      if (e.preventdefault) e.preventdefault();                      scope.ondragover();                     return false;                 }else{                     e.datatransfer.dropeffect = 'none';                 }              };                     //,true);              var removelisteners = function(){                 el.removeeventlistener("dragover", fndragover);             };             var addlisteners = function(){                 el.addeventlistener("dragover", fndragover, false);             };              attrs.$observe("droppable", function (value) {                 if(value == "false"){                     removelisteners();                 }else{                     addlisteners();                 }             });           }     }; }); 


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -