1

Is there any solution that can implement the click away feature with ng-show?

Here is the plunker: http://jsfiddle.net/o0dwsrqf/

I'm using the button to show the text.

<button ng-click="test=!test">test</button>

And I'm using ng-show to show the text:

<ul ng-show="test">

And when I click away from the text I want to hide it. Is there anyway I can achieve this?

EDIT:

Defining click away I mean click anywhere else besides button and text area. When I click away I want to hide the text.

Gabriel
  • 601
  • 1
  • 10
  • 26

1 Answers1

1

You need to use event propagation to do this. Attach a click event to the body tag or some other element that covers the entire page and then attach click events to the button and text area. The button should toggle test and swallow the event (e.stopPropagation()) and the textarea should get focus then swallow the event.

tuckerjt07
  • 902
  • 1
  • 12
  • 31