How to make Dropdown using Angular UI Bootstrap ? - GeeksforGeeks

06 Jun, 2021
In this article, we will see how to make Dropdown using Angular UI bootstrap. Angular UI Bootstrap is an Angular JS framework created by Angular UI developers for providing better UI which can be used easily.
Syntax:
<div uib-dropdown></div>
Download AngularUI from the link:
https://angular-ui.github.io/bootstrap
 
Approach: 
First, add Angular UI bootstrap scripts needed for your project.
<script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js”></script><script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js”></script><script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js”></script><script src=”https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js”></script>
Make dropdown with its UIBootStrap classes which will set the UI look for the dropdown.
Now make different types of dropdown using different classes and run the code.
Example:
HTML
<!DOCTYPE html><html ng-app="gfg">  <head>      <!-- Adding CDN scripts required for our page -->    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js">    </script>    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js">    </script>    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js">    </script>    <script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js">    </script>      <script>      // Adding Modules      angular.module('gfg', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);      angular.module('gfg').controller('button', function ($scope) {        });    </script>    <link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"           rel="stylesheet">  </head>  <body>    <div ng-controller="button">        <!-- making a dropdown -->      <div class="btn-group" uib-dropdown>        <button type="button" class="btn btn-success">Click</button>        <button type="button" class="btn btn-success" uib-dropdown-toggle>          <span class="caret"></span>        </button>        <ul class="dropdown-menu"             uib-dropdown-menu role="menu"             aria-labelledby="split-button">          <li role="menuitem">1st</li>          <li role="menuitem">2nd</li>          <li role="menuitem">3rd</li>          <li role="menuitem">5th</li>        </ul>      </div>        <div class="btn-group" uib-dropdown>        <button type="button"                 class="btn btn-danger">Click</button>        <button type="button"                 class="btn btn-danger" uib-dropdown-toggle>          <span class="caret"></span>        </button>        <ul class="dropdown-menu"             uib-dropdown-menu role="menu"            aria-labelledby="split-button">          <li role="menuitem">1st</li>          <li role="menuitem">2nd</li>          <li role="menuitem">3rd</li>          <li role="menuitem">5th</li>        </ul>      </div>      <div class="btn-group" uib-dropdown>        <button type="button" class="btn btn-warning">Click</button>        <button type="button"                 class="btn btn-warning"                 uib-dropdown-toggle>          <span class="caret"></span>        </button>        <ul class="dropdown-menu"             uib-dropdown-menu role="menu"             aria-labelledby="split-button">          <li role="menuitem">1st</li>          <li role="menuitem">2nd</li>          <li role="menuitem">3rd</li>          <li role="menuitem">5th</li>        </ul>      </div>    </div>    </body></html>
Output:
Reference: https://angular-ui.github.io/bootstrap/#!#dropdown
Angular-UI
AngularUI-Bootstrap
Bootstrap-Questions
AngularJS
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Angular Libraries For Web Developers
How to use <mat-chip-list> and <mat-chip> in Angular Material ?
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
Angular 10 (focus) Event
Form validation using jQuery
How to change navigation bar color in Bootstrap ?
How to set Bootstrap Timepicker using datetimepicker library ?
How to align navbar items to the right in Bootstrap 4 ?
How to Show Images on Click using HTML ?