Reset the scope using an onclick event with AngularJS

iamsar

I have a scope variable that gets set when a user clicks an element. I would simply like to change that variable to false when a user clicks outside the element. Common convention for modals or popup menus.

I have a plunker demonstrating my code and the problem. It's based off another plunker I started so it may seem extraneous but it is indicative of my exact issue.

http://plnkr.co/edit/O7YwaPci894XjX7XgsGe?p=preview

rvignacio

Add a ng-focus and a ng-blur directive to the element.

In order to use these directives on elements different than input, select, textarea, a first add a tabindex attribute to the element:

<p tabindex="0" data-ng-focus="setScopeVariable()" data-ng-blur="resetScopeVariable()">Click me!</p>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

angularjs scope variable change onclick for conditional div

From Dev

How to redirect a page using onclick event in php?

From Dev

Using this within functions called with onclick event in Javascript

From Dev

Get AngularJs $scope in History popstate event?

From Dev

AngularJS - the scope is reset in the linking function, what am I doing wrong?

From Dev

Onclick event issue after using the outerHTML

From Dev

AngularJS - Adding an onClick event to a Button via a Directive

From Dev

Using wijmo event calender with angularjs

From Dev

AngularJS using $apply without $scope

From Dev

How to call a AngularJS controller using onclick event

From Dev

AngularJS event-based communication through isolate scope

From Dev

How to pass value back from angularjs directive scope with javascript event

From Dev

javascript add event listener not working with angularjs $scope

From Dev

jQuery: Disable onclick event using off() not working

From Dev

using angularjs $timeout with "this" insted of $scope

From Dev

using a timeout and scope apply - angularjs

From Dev

Component in AngularJS 1.5 doesn't listen Broadcasted event from $scope

From Dev

Disable Onclick event using jquery

From Dev

How to change the onclick event of a link using the onclick event of a radio button?

From Dev

AngularJS event-based communication through isolate scope

From Dev

How to pass value back from angularjs directive scope with javascript event

From Dev

Trigger AngularJS $scope event on key press

From Dev

AngularJS Get Filtered Scope onClick

From Dev

Reset a input as able again on onClick event after be disable

From Dev

AngularJs #how to pass scope variable in on change event in directive in input file

From Dev

AngularJs - call $scope function on the onclick event from <img> tag

From Dev

Looping through scope using Angularjs

From Dev

get echarts on click event to change value of variable attached to $scope in angularjs

From Dev

Reset scope interval in angularjs directive creating loop

Related Related

  1. 1

    angularjs scope variable change onclick for conditional div

  2. 2

    How to redirect a page using onclick event in php?

  3. 3

    Using this within functions called with onclick event in Javascript

  4. 4

    Get AngularJs $scope in History popstate event?

  5. 5

    AngularJS - the scope is reset in the linking function, what am I doing wrong?

  6. 6

    Onclick event issue after using the outerHTML

  7. 7

    AngularJS - Adding an onClick event to a Button via a Directive

  8. 8

    Using wijmo event calender with angularjs

  9. 9

    AngularJS using $apply without $scope

  10. 10

    How to call a AngularJS controller using onclick event

  11. 11

    AngularJS event-based communication through isolate scope

  12. 12

    How to pass value back from angularjs directive scope with javascript event

  13. 13

    javascript add event listener not working with angularjs $scope

  14. 14

    jQuery: Disable onclick event using off() not working

  15. 15

    using angularjs $timeout with "this" insted of $scope

  16. 16

    using a timeout and scope apply - angularjs

  17. 17

    Component in AngularJS 1.5 doesn't listen Broadcasted event from $scope

  18. 18

    Disable Onclick event using jquery

  19. 19

    How to change the onclick event of a link using the onclick event of a radio button?

  20. 20

    AngularJS event-based communication through isolate scope

  21. 21

    How to pass value back from angularjs directive scope with javascript event

  22. 22

    Trigger AngularJS $scope event on key press

  23. 23

    AngularJS Get Filtered Scope onClick

  24. 24

    Reset a input as able again on onClick event after be disable

  25. 25

    AngularJs #how to pass scope variable in on change event in directive in input file

  26. 26

    AngularJs - call $scope function on the onclick event from <img> tag

  27. 27

    Looping through scope using Angularjs

  28. 28

    get echarts on click event to change value of variable attached to $scope in angularjs

  29. 29

    Reset scope interval in angularjs directive creating loop

HotTag

Archive