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.

Plugin dependency

Dropdowns require the tooltip plugin to be included.

Live demo clog.info

$scope.dropdown = {{dropdown | json}};

Append a bs-dropdownattribute to any element to enable the directive.

The module exposes a $dropdownservice

Available for programmatic use (mainly in directives as it requires a DOM element).

        
          var myDropdown = $dropdown(element, {scope: {content: [{text:'foo', href:'', click:''}, ...]});
        
      

Options

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

This module supports exotic placement options!

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: delay: { show: 500, hide: 100 }

container string | false false

Appends the dropdown to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the dropdown in the flow of the document near the triggering element - which will prevent the dropdown from floating away from the triggering element during a window resize.

template path false

If provided, overrides the default template, can be either a remote URL or a cached template id.

Default options

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'
            });
          })