Provides a directive to specifiy a behaviour when click/tap events happen outside an element. This can be easily used to implement eg. close on outer click feature for a dropdown.
Usage
Declare it as a dependency to your app unless you have already included some of its super-modules.
angular.module('myApp', ['mobile-angular-ui']);
Or
angular.module('myApp', ['mobile-angular-ui.core']);
Or
angular.module('myApp', ['mobile-angular-ui.core.outerClick']);
Use ui-outer-click
to define an expression to evaluate when an Outer Click event happens. Use ui-outer-click-if
parameter to define a condition to enable/disable the listener.
<div class="btn-group">
<a ui-turn-on='myDropdown' class='btn'>
<i class="fa fa-ellipsis-v"></i>
</a>
<ul
class="dropdown-menu"
ui-outer-click="Ui.turnOff('myDropdown')"
ui-outer-click-if="Ui.active('myDropdown')"
role="menu"
ui-show="myDropdown"
ui-shared-state="myDropdown"
ui-turn-off="myDropdown">
<li><a>Action</a></li>
<li><a>Another action</a></li>
<li><a>Something else here</a></li>
<li class="divider"></li>
<li><a>Separated link</a></li>
</ul>
</div>
Services
bindOuterClick service
This is a service function that binds a callback to be conditionally executed when a click event happens outside a specified element.
Ie.
app.directive('myDirective', function('bindOuterClick'){
return {
link: function(scope, element) {
bindOuterClick(element, function(scope, extra){
alert('You clicked ouside me!');
}, function(e){
return element.hasClass('disabled') ? true : false;
});
}
};
});
Param | Type | Description |
---|---|---|
element | DomElement | $element | The element to bind to. |
callback | function | A |
condition | string | function | Angular |
Directives
outerClick directive
Evaluates an expression when an Outer Click event happens.
Param | Type | Description |
---|---|---|
uiOuterClick | expression | Expression to evaluate when an Outer Click event happens. |
uiOuterClickIf | expression | Condition to enable/disable the listener. Defaults to |
comments powered by Disqus