Open In App

How to make Timepicker 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 to provide better UI which can be used easily.



Syntax:

<div uib-timepicker></div>

Download AngularUI from the link:



https://angular-ui.github.io/bootstrap

 

Approach: 

<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>

Example:




<!DOCTYPE html>
<html ng-app="gfg">
  <head>
  
  <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script>
      // Adding Modules
      angular.module('gfg', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);
      angular.module('gfg').controller('timepicker', function ($scope) {
        $scope.ismeridian = true;
        $scope.lcltime = new Date();
        $scope.hrs = 1;
        $scope.mnt = 1;
  
      });
    </script>
  
    <link href=
          rel="stylesheet">
  
  </head>
  <body>
    <div ng-controller="timepicker">
  
      <!-- making a timepicker -->
      <div class="column">
  
         <div uib-timepicker ng-model="lcltime"
              ng-change="changed()" hour-step="hrs" 
              minute-step="mnt" show-meridian="ismeridian">
         </div>
  
           <pre class="alert alert-info">
           Local time: {{lcltime | date:'shortTime' }}
           </pre>
        </div>
      </div>
  </body>
</html>

Output:

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


Article Tags :