angularjs - Apply Angular JS Directive if element is visible -


i have written below directive close <a> element on click outside itself, , want directive start executing if element visible; executing on every click event on document despite element visible or not.

app.directive("outsideclick", ['$document','$parse', function( $document, $parse ){             return {                 link: function( $scope, $element, $attributes ){                     var scopeexpression = $attributes.outsideclick,                         ondocumentclick = function(event){                             var ischild = $element.find(event.target).length > 0;                             if(!ischild) {                                     $scope.$apply(scopeexpression);                             }                         };                      $document.on("click", ondocumentclick);                      $element.on('$destroy', function() {                         $document.off("click", ondocumentclick);                     });                 }             }         }]); 


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -