Mobile Angular UI - outerClick
As per the name Outerclick it helps to add a behaviour based on click/tap that happens outside the html element. It is mostly useful to close dropdowns that are open when clicked outside the dropdown area.
The core sub-module outerClick comes with two important directives called as ui-outer-click and ui-outer-click-if.
Let us take a look at an example −
We will add the changes in src/home/home.html.
<div class="list-group text-center">
<div class="list-group-item list-group-item-home">
<h1>{{msg}}</h1>
</div>
<div class="list-group-item list-group-item-home">
<div class="btn-group">
<a ui-turn-on='testDropdown' class='btn'>
<i class="fa fa-caret-down" aria-hidden="true"></i>Tutorials
</a>
<ul
class="dropdown-menu"
ui-outer-click="Ui.turnOff('testDropdown')"
ui-outer-click-if="Ui.active('testDropdown')"
role="menu"
ui-show="testDropdown"
ui-state="testDropdown"
ui-turn-off="testDropdown">
<li><a>PHP</a></li>
<li><a>JAVA</a></li>
<li><a>MYSQL</a></li>
<li class="divider"></li>
<li><a>PYTHON</a></li>
</ul>
</div>
</div>
</div>
Make use of ui-outer-click to when Outer Click event happens. You can also call a function to do something specific as per your project. Make use of Use ui-outer-click-if parameter to enable/disable the listener.
We are having a list of Tutorials shown in the dropdown. The output on the screen is as follows −
mobile_angular_ui_core_details.htm
Advertisements