mgcrea.ngStrap.dropdown
Add dropdown menus to nearly anything with this simple plugin, including the navbar, tabs, and pills.
Append a bs-dropdown
attribute to any element to enable the plugin.
Dropdowns require the tooltip plugin to be included.
$scope.dropdown = {{dropdown | json}};
Append a bs-dropdown
attribute to any element to enable the directive.
$dropdown
serviceAvailable for programmatic use (mainly in directives as it requires a DOM element).
var myDropdown = $dropdown(element, {scope: {content: [{text:'foo', href:'', click:''}, ...]});
Options can be passed via data-attributes on the directive or as an object hash to configure the service. For data attributes, append the option name to data-
, as in data-animation=""
.
For directives, you can naturally inherit the contextual $scope
or leverage a custom one with an AngularJS expression to evaluate as an object directly on the bs-dropdown
attribute
You can position your dropdown in corners (such as bottom-left
) or any other combination two.
Exotic placement options are not part of the Bootstrap's core, to use them you must use bootstrap-additions.css
from the BootstrapAdditions project. This project being not yet fully released, meanwhile, you can use the development snapshot compiled for theses docs.
Name | type | default | description |
---|---|---|---|
animation | string | am-fade | apply a CSS animation powered by ngAnimate |
placement | string | 'bottom-left' |
how to position the dropdown - top | bottom | left | right | auto, or any combination like bottom-left or auto bottom-left. When "auto" is specified, it will dynamically reorient the dropdown. For example, if placement is "auto left", the dropdown will display to the left when possible, otherwise it will display right. |
trigger | string | 'click' | how dropdown is triggered - click | hover | focus | manual |
html | boolean | false | replace ng-bind with ng-bind-html , requires ngSanitize to be loaded |
delay | number | object | 0 |
delay showing and hiding the dropdown (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is:
|
container | string | false | false |
Appends the dropdown to a specific element. Example:
|
template | path | false |
If provided, overrides the default template, can be either a remote URL or a cached template id. |
You can override global defaults for the plugin with $dropdownProvider.defaults
angular.module('myApp')
.config(function($dropdownProvider) {
angular.extend($dropdownProvider.defaults, {
animation: 'am-flip-x',
trigger: 'hover'
});
})