Trigger event when clicked outside the input element in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 09:09 PM
Hello All,
I am trying to show and hide a div element based on click event on an element in another widget.
I am able to show the element using the $broadcast and $on but I am not sure how can we hide the element if we click outside the input element.
Please help how can we resolve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 09:15 PM
Hi
For implement the same mechanism, directives ng-show and ng-hide are also used.
Differences between ng-if and ng-show(ng-hide):
ng-show (and its sibling ng-hide) toggle the appearance of the element by adding the CSS display: none style.
ng-if, on the other hand, actually removes the element from the DOM when the condition is false and only adds the element back once the condition turns true.
The best practice is to use ng-if because ng-show spends more time.
If it help mark helpful or correct
Thanks and regards
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 12:00 AM
Hello Anil,
But how can we achieve the false condition? I am already using ng-if to show when the flag is true, but how to make the flag false when the user clicks outside the input element?
