How to make Tooltip using Angular UI Bootstrap ?

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-tooltip></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 Tooltip with its UIBootStrap classes which will set the UI look for the Tooltip.
  • Now make different types of Tooltip 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('tooltip', function ($scope) {
        $scope.gfg = {
          options: [
            'one',
            'two',
            'three',
            'four',
            'five',
            'six',
            'seven',
            'eight',
            'nine',
            'ten',
            'eleven',
            'twelve'
          ],
          selected: 'one'
        };
      });
    </script>
  
    <link href=
"https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
          rel="stylesheet">
  
  </head>
  <body>
    <div ng-controller="tooltip">
  
      <!-- making a tooltip -->
      <div class="column">
  
        <div class="form-group">
  
          <select class="form-control" 
                  ng-model="gfg.selected" 
                  ng-options="o as o for o in gfg.options">
          </select>
        </div>
  
        <button tooltip-placement="{{gfg.selected}}" 
                type="button" class="btn btn-success">
          Tooltip {{gfg.selected}}
        </button>
  
      </div>
    </div>
  </body>
</html>


Output:

Reference: https://angular-ui.github.io/bootstrap/#!#tooltip