AngularJS $scope variable on window onclick -


I have a button, which shows a window to be clicked and hides the button when the button is clicked again is. I want to close the window even if some other location is clicked in the page.

This is my code:

  & lt; A class = "btn dropdown-toggle multiselect-btn" ng-click = "! Content = content; contentClick = true" & gt; // To hide the div & lt; Div ng-class = "{'open': content}" & gt; Div content & lt; / Div & gt;   

I wrote the following window on the click code in the controller but it does not work.

  $ window.onclick = function () {if ($ Scope.contentClick) {$ scope.contentClick = 0; } And {$ scope.content = false; $ Scope $ Apply ();}}   

What is the correct way to do this? Can someone guide me in the right direction.Thank you

Try it out, change your controller ID:

  window.onclick = Function () {var scope =. Angular.element (document.getElementById ('controller_id')) scope (); If (scope.contentClick) {scope.contentClick = 0; } And {scope.content = false; . Scope $ apply (); }}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -