I have a popup that i want to close when clicked anywhere else on screen, I do this by triggering $document.bind('click',function(){...});
inside the open function $scope.open = function(){...}
.
I also have another function for close $scope.close = function(){...}
The objective is to remove the bind inside the close function.
I am new to angular and so unfortunately I dont fully understand the answers I've found on this questions. Theoretically, I know I might be able to achieve this with $destroy
, but I have no idea how to physically implement it. Can someone please teach me how to do this?
EDIT: I am doing this in controllers & directives.