Accordion (ui.bootstrap.accordion)
The body of the uib-accordion group grows to fit the contents
Please, to delete your account, click the button below
<div ng-controller="AccordionDemoCtrl">
<script type="text/ng-template" id="group-template.html">
<div class="panel-heading">
<h4 class="panel-title" style="color:#fa39c3">
<a href tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" uib-accordion-transclude="heading">
<span uib-accordion-header ng-class="{'text-muted': isDisabled}">
{{heading}}
</span>
</a>
</h4>
</div>
<div class="panel-collapse collapse" uib-collapse="!isOpen">
<div class="panel-body" style="text-align: right" ng-transclude></div>
</div>
</script>
<p>
<button type="button" class="btn btn-default btn-sm" ng-click="status.open = !status.open">Toggle last panel</button>
<button type="button" class="btn btn-default btn-sm" ng-click="status.isFirstDisabled = ! status.isFirstDisabled">Enable / Disable first panel</button>
</p>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="oneAtATime">
Open only one at a time
</label>
</div>
<uib-accordion close-others="oneAtATime">
<div uib-accordion-group class="panel-default" heading="Static Header, initially expanded" is-open="status.isFirstOpen" is-disabled="status.isFirstDisabled">
This content is straight in the template.
</div>
<div uib-accordion-group class="panel-default" heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</div>
<div uib-accordion-group class="panel-default" heading="Dynamic Body Content">
<p>The body of the uib-accordion group grows to fit the contents</p>
<button type="button" class="btn btn-default btn-sm" ng-click="addItem()">Add Item</button>
<div ng-repeat="item in items">{{item}}</div>
</div>
<div uib-accordion-group class="panel-default" heading="Custom template" template-url="group-template.html">
Hello
</div>
<div uib-accordion-group class="panel-default" is-open="status.isCustomHeaderOpen" template-url="group-template.html">
<uib-accordion-heading>
Custom template with custom header template <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.isCustomHeaderOpen, 'glyphicon-chevron-right': !status.isCustomHeaderOpen}"></i>
</uib-accordion-heading>
World
</div>
<div uib-accordion-group class="panel-danger" heading="Delete account">
<p>Please, to delete your account, click the button below</p>
<button class="btn btn-danger">Delete</button>
</div>
<div uib-accordion-group class="panel-default" is-open="status.open">
<uib-accordion-heading>
I can have markup, too! <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.open, 'glyphicon-chevron-right': !status.open}"></i>
</uib-accordion-heading>
This is just some content to illustrate fancy headings.
</div>
</uib-accordion>
</div>
angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) {
$scope.oneAtATime = true;
$scope.groups = [
{
title: 'Dynamic Group Header - 1',
content: 'Dynamic Group Body - 1'
},
{
title: 'Dynamic Group Header - 2',
content: 'Dynamic Group Body - 2'
}
];
$scope.items = ['Item 1', 'Item 2', 'Item 3'];
$scope.addItem = function() {
var newItemNo = $scope.items.length + 1;
$scope.items.push('Item ' + newItemNo);
};
$scope.status = {
isCustomHeaderOpen: false,
isFirstOpen: true,
isFirstDisabled: false
};
});
uib-accordion settings
close-others
$ C (Default:true
) - Control whether expanding an item will cause the other items to close.template-url
(Default:template/accordion/accordion.html
) - Add the ability to override the template used on the component.
uib-accordion-group settings
heading
(Default:none
) - The clickable text on the group's header. You need one to be able to click on the header for toggling.is-disabled
$ (Default:false
) - Whether the accordion group is disabled or not.is-open
$ (Default:false
) - Whether accordion group is open or closed.template-url
(Default:uib/template/accordion/accordion-group.html
) - Add the ability to override the template used on the component.
Accordion heading
Instead of the heading
attribute on the uib-accordion-group
, you can use an uib-accordion-heading
element inside a group that will be used as the group's header.
If you're using a custom template for the uib-accordion-group
, you'll need to have an element for the heading to be transcluded into using uib-accordion-header
(e.g. <div uib-accordion-header></div>
).
Known issues
To use clickable elements within the accordion, you have to override the accordion-group template to use div elements instead of anchor elements, and add cursor: pointer
in your CSS. This is due to browsers interpreting anchor elements as the target of any click event, which triggers routing when certain elements such as buttons are nested inside the anchor element.
If custom classes on the accordion-group element are desired, one needs to either modify the template to remove the ng-class
usage in the accordion-group template and use ng-class on the accordion-group element (not recommended), or use an interpolated expression in the class attribute, i.e. <uib-accordion-group class=""></uib-accordion-group>
.
Alert (ui.bootstrap.alert)
<div ng-controller="AlertDemoCtrl">
<script type="text/ng-template" id="alert.html">
<div ng-transclude></div>
</script>
<div uib-alert ng-repeat="alert in alerts" ng-class="'alert-' + (alert.type || 'warning')" close="closeAlert($index)">{{alert.msg}}</div>
<div uib-alert template-url="alert.html" style="background-color:#fa39c3;color:white">A happy alert!</div>
<button type="button" class='btn btn-default' ng-click="addAlert()">Add Alert</button>
</div>
angular.module('ui.bootstrap.demo').controller('AlertDemoCtrl', function ($scope) {
$scope.alerts = [
{ type: 'danger', msg: 'Oh snap! Change a few things up and try submitting again.' },
{ type: 'success', msg: 'Well done! You successfully read this important alert message.' }
];
$scope.addAlert = function() {
$scope.alerts.push({msg: 'Another alert!'});
};
$scope.closeAlert = function(index) {
$scope.alerts.splice(index, 1);
};
});
This directive can be used both to generate alerts from static and dynamic model data (using the ng-repeat
directive).
uib-alert settings
close()
$ - A callback function that gets fired when analert
is closed. If the attribute exists, a close button is displayed as well.dismiss-on-timeout
(Default:none
) - Takes the number of milliseconds that specify the timeout duration, after which the alert will be closed. This attribute requires the presence of theclose
attribute.template-url
(Default:uib/template/alert/alert.html
) - Add the ability to override the template used in the component.
Collapse (ui.bootstrap.collapse)
Resize window to less than 768 pixels to display mobile menu toggle button.
<style>
.horizontal-collapse {
height: 70px;
}
.navbar-collapse.in {
overflow-y: hidden;
}
</style>
<div ng-controller="CollapseDemoCtrl">
<p>Resize window to less than 768 pixels to display mobile menu toggle button.</p>
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" ng-click="isNavCollapsed = !isNavCollapsed">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">A menu</a>
</div>
<div class="collapse navbar-collapse" uib-collapse="isNavCollapsed">
<ul class="nav navbar-nav">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
</ul>
</div>
</nav>
<hr>
<button type="button" class="btn btn-default" ng-click="isCollapsed = !isCollapsed">Toggle collapse Vertically</button>
<hr>
<div uib-collapse="isCollapsed">
<div class="well well-lg">Some content</div>
</div>
<button type="button" class="btn btn-default" ng-click="isCollapsedHorizontal = !isCollapsedHorizontal">Toggle collapse Horizontally</button>
<hr>
<div class="horizontal-collapse" uib-collapse="isCollapsedHorizontal" horizontal>
<div class="well well-lg">Some content</div>
</div>
</div>
app.controller('CollapseDemoCtrl', function ($scope) {
$scope.isNavCollapsed = true;
$scope.isCollapsed = false;
$scope.isCollapsedHorizontal = false;
});
uib-collapse provides a simple way to hide and show an element with a css transition
uib-collapse settings
collapsed()
$ - An optional expression called after the element finished collapsing.collapsing()
$ - An optional expression called before the element begins collapsing. If the expression returns a promise, animation won't start until the promise resolves. If the returned promise is rejected, collapsing will be cancelled.expanded()
$ - An optional expression called after the element finished expanding.expanding()
$ - An optional expression called before the element begins expanding. If the expression returns a promise, animation won't start until the promise resolves. If the returned promise is rejected, expanding will be cancelled.uib-collapse
$ (Default:false
) - Whether the element should be collapsed or not.horizontal
$ - An optional attribute that permit to collapse horizontally.
Known Issues
When using the horizontal
attribute with this directive, keep in mind that due to how CSS can reflow as the collapse element goes from 0px to its desired end width, this cause result in issues with a changing height. This can cause animations to not appear to run. The best way around this is to set a fixed height via CSS on the horizontal collapse element so that this situation does not occur, and so the animation can run as expected.
Dateparser (ui.bootstrap.dateparsert)
The uibDateParser
is what the uib-datepicker
uses internally to parse the dates. You can use it standalone by injecting the uibDateParser
service where you need it.
The public API for the dateParser is a single method called parse
.
Certain format codes support i18n. Check this guide for more information.
Formatting codes playground
<div ng-controller="DateParserDemoCtrl">
<h4>Formatting codes playground</h4>
<p class="form-group">
<label>Define your format</label>
<input type="text" ng-model="format" class="form-control">
</p>
<p class="form-group">
<label>Result</label>
<input type="text" class="form-control" uib-datepicker-popup="" ng-model="date" />
</p>
</div>
app.controller('DateParserDemoCtrl', function ($scope, uibDateParser) {
$scope.format = 'yyyy/MM/dd';
$scope.date = new Date();
});
uibDateParser's parse function
parameters
input
(Type:string
, Example:2004/Sep/4
) - The input date to parse.format
(Type:string
, Example:yyyy/MMM/d
) - The format we want to use. Check all the supported formats below.baseDate
(Type:Date
, Example:new Date()
) - If you want to parse a date but maintain the timezone, you can pass an existing date here.
return
- If the specified input matches the format, a new date with the input will be returned, otherwise, it will return undefined.
uibDateParser's format codes
yyyy
(Example:2015
) - Parses a 4 digits year.yy
(Example:15
) - Parses a 2 digits year.y
(Example:15
) - Parses a year with 1, 2, 3, or 4 digits.MMMM
(Example:February
, i18n support) - Parses the full name of a month.MMM
(Example:Feb
, i18n support) - Parses the short name of a month.MM
(Example:12
, Leading 0) - Parses a numeric month.M
(Example:3
) - Parses a numeric month.M!
(Example:3
or03
) - Parses a numeric month, but allowing an optional leading zeroLLLL
(Example:February
, i18n support) - Stand-alone month in year (January-December). Requires Angular version 1.5.1 or higher.dd
(Example:05
, Leading 0) - Parses a numeric day.d
(Example:5
) - Parses a numeric day.d!
(Example:3
or03
) - Parses a numeric day, but allowing an optional leading zeroEEEE
(Example:Sunday
, i18n support) - Parses the full name of a day.EEE
(Example:Mon
, i18n support) - Parses the short name of a day.HH
(Example:14
, Leading 0) - Parses a 24 hours time.H
(Example:3
) - Parses a 24 hours time.hh
(Example:11
, Leading 0) - Parses a 12 hours time.h
(Example:3
) - Parses a 12 hours time.mm
(Example:09
, Leading 0) - Parses the minutes.m
(Example:3
) - Parses the minutes.sss
(Example:094
, Leading 0) - Parses the milliseconds.ss
(Example:08
, Leading 0) - Parses the seconds.s
(Example:22
) - Parses the seconds.a
(Example:10AM
) - Parses a 12 hours time with AM/PM.Z
(Example:-0800
) - Parses the timezone offset in a signed 4 digit representationww
(Example:03
, Leading 0) - Parses the week numberw
(Example:03
) - Parses the week numberG
,GG
,GGG
(Example:AD
) - Parses the era (AD
orBC
)GGGG
(Example:Anno Domini
) - Parses the long form of the era (Anno Domini
orBefore Christ
)
* The ones marked with Leading 0
, needs a leading 0 for values less than 10. Exception being milliseconds which needs it for values under 100.
** It also supports fullDate|longDate|medium|mediumDate|mediumTime|short|shortDate|shortTime
as the format for parsing.
*** It supports template literals as a string between the single quote '
character, i.e. 'The Date is' MM/DD/YYYY
. If one wants the literal single quote character, one must use ''''
.
Datepicker (bootstrap-datepicker)
<button type="button" class="btn btn-default" bt-date-picker="date">Click me!</button>
You selected <span ng-bind="date.value"></span>
Add bootstrap-datepicker as a dependency in bower.json, .
"bootstrap-datepicker": "1.3.1"
Then run:
bower install
In src/main/webapp/index.html, add links to the CSS and JS files:
<head>
...
<link rel="stylesheet" src="bower_components/bootstrap-datepicker/css/datepicker.css">
...
</head>
<script src="bower_components/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
Example:
<div class="form-group">
<label for="birthdate">Birth Date</label>
<input type="text" class="form-control" name="birthdate" data-provide="datepicker">
</div>
Dropdown (ui.bootstrap.dropdownToggle)
Dropdown is a simple directive which will toggle a dropdown menu on click or programmatically.
This directive is composed by three parts:
uib-dropdown
which transforms a node into a dropdown.uib-dropdown-toggle
which allows the dropdown to be toggled via click. This directive is optional.uib-dropdown-menu
which transforms a node into the popup menu.
Each of these parts need to be used as attribute directives.
<div ng-controller="DropdownCtrl">
<!-- Simple dropdown -->
<span uib-dropdown on-toggle="toggled(open)">
<a href id="simple-dropdown" uib-dropdown-toggle>
Click me for a dropdown, yo!
</a>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="simple-dropdown">
<li ng-repeat="choice in items">
<a href>{{choice}}</a>
</li>
</ul>
</span>
<!-- Single button -->
<div class="btn-group" uib-dropdown is-open="status.isopen">
<button id="single-button" type="button" class="btn btn-primary" uib-dropdown-toggle ng-disabled="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
<!-- Split button -->
<div class="btn-group" uib-dropdown>
<button id="split-button" type="button" class="btn btn-danger">Action</button>
<button type="button" class="btn btn-danger" uib-dropdown-toggle>
<span class="caret"></span>
<span class="sr-only">Split button!</span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="split-button">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
<!-- Single button using append-to-body -->
<div class="btn-group" uib-dropdown dropdown-append-to-body>
<button id="btn-append-to-body" type="button" class="btn btn-primary" uib-dropdown-toggle>
Dropdown on Body <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="btn-append-to-body">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
<!-- Single button using template-url -->
<div class="btn-group" uib-dropdown>
<button id="button-template-url" type="button" class="btn btn-primary" uib-dropdown-toggle ng-disabled="disabled">
Dropdown using template <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu template-url="dropdown.html" aria-labelledby="button-template-url">
</ul>
</div>
<hr />
<p>
<button type="button" class="btn btn-default btn-sm" ng-click="toggleDropdown($event)">Toggle button dropdown</button>
<button type="button" class="btn btn-warning btn-sm" ng-click="disabled = !disabled">Enable/Disable</button>
</p>
<hr>
<!-- Single button with keyboard nav -->
<div class="btn-group" uib-dropdown keyboard-nav>
<button id="simple-btn-keyboard-nav" type="button" class="btn btn-primary" uib-dropdown-toggle>
Dropdown with keyboard navigation <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="simple-btn-keyboard-nav">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
<hr>
<!-- AppendTo use case -->
<h4>append-to vs. append-to-body vs. inline example</h4>
<div id="dropdown-scrollable-container" style="height: 15em; overflow: auto;">
<div id="dropdown-long-content">
<div id="dropdown-hidden-container">
<div class="btn-group" uib-dropdown keyboard-nav dropdown-append-to="appendToEl">
<button id="btn-append-to" type="button" class="btn btn-primary" uib-dropdown-toggle>
Dropdown in Container <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="btn-append-to">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
<div class="btn-group" uib-dropdown dropdown-append-to-body>
<button id="btn-append-to-to-body" type="button" class="btn btn-primary" uib-dropdown-toggle>
Dropdown on Body <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="btn-append-to-to-body">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
<div class="btn-group" uib-dropdown>
<button id="btn-append-to-single-button" type="button" class="btn btn-primary" uib-dropdown-toggle>
Inline Dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="btn-append-to-single-button">
<li role="menuitem"><a href="#">Action</a></li>
<li role="menuitem"><a href="#">Another action</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link</a></li>
</ul>
</div>
</div>
</div>
</div>
<script type="text/ng-template" id="dropdown.html">
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="button-template-url">
<li role="menuitem"><a href="#">Action in Template</a></li>
<li role="menuitem"><a href="#">Another action in Template</a></li>
<li role="menuitem"><a href="#">Something else here</a></li>
<li class="divider"></li>
<li role="menuitem"><a href="#">Separated link in Template</a></li>
</ul>
</script>
</div>
angular.module('ui.bootstrap.demo').controller('DropdownCtrl', function ($scope, $log) {
$scope.items = [
'The first choice!',
'And another choice for you.',
'but wait! A third!'
];
$scope.status = {
isopen: false
};
$scope.toggled = function(open) {
$log.log('Dropdown is now: ', open);
};
$scope.toggleDropdown = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.status.isopen = !$scope.status.isopen;
};
$scope.appendToEl = angular.element(document.querySelector('#dropdown-long-content'));
});
uib-dropdown settings
auto-close
(Default:always
) - Controls the behavior of the menu when clicked.always
- Automatically closes the dropdown when any of its elements is clicked.disabled
- Disables the auto close. You can control it manually withis-open
. It still gets closed if the toggle is clicked,esc
is pressed or another dropdown is open.outsideClick
- Closes the dropdown automatically only when the user clicks any element outside the dropdown.
dropdown-append-to
$ (Default:null
) - Appends the inner dropdown-menu to an arbitrary DOM element.dropdown-append-to-body
B (Default:false
) - Appends the inner dropdown-menu to the body element.is-open
$ (Default:false
) - Defines whether or not the dropdown-menu is open. Theuib-dropdown-toggle
will toggle this attribute on click.keyboard-nav
: B (Default:false
) - Enables navigation of dropdown list elements with the arrow keys.on-toggle(open)
$ - An optional expression called when the dropdown menu is opened or closed.
uib-dropdown-menu settings
template-url
(Default:none
) - You may specify a template for the dropdown menu. Check the demos for an example.
Additional settings uibDropdownConfig
appendToOpenClass
(Default:uib-dropdown-open
) - Class to apply when the dropdown is open and appended to a different DOM element.openClass
(Default:open
) - Class to apply when the dropdown is open.
Known issues
For usage with ngTouch, it is recommended to use the programmatic is-open
trigger with ng-click - this is due to ngTouch decorating ng-click to prevent propagation of the event.
Fixed table header (Fixed-Table-Header)
# | Name | Birthday | Citizenship | Favorite Food and Drink |
---|---|---|---|---|
[[ person.nr ]] | [[ person.firstName ]] [[ person.lastName ]] | [[ person.citizenText ]] |
[[ person.food ]] [[ person.drink ]] |
Usage
Wrap the table in a element that will scroll vertically. Use the fix-head
attribute on a <thead>
element to prevent it from scrolling with the rest of the table.
A clone of the original <thead>
element will be moved outside the scroll container. To ensure valid HTML, the cloned <thead>
element will be wrapped in a copy of the <table>
element. The new <table>
element will be given the clone
class.
<div style="overflow: auto; max-height: 300px;">
<table>
<thead fix-head>
<tr>
<th>Nr</th>
<th>Name</th>
<th>Birthday</th>
<th>Citizenship</th>
<th>Favorite Food and Drink</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="contact in contacts">
<td>{{contact.nr}}</td>
<td>{{contact.name}}</td>
<td>{{contact.birthday}}</td>
<td>{{contact.citizenship}}</td>
<td>{{contact.favoritefood}}</td>
</tr>
</tbody>
</table>
</div>
This package is installable through the Bower package manager.
bower install angular-fixed-table-header --save
Using Bower
In your index.html
file, include the source file.
<script type="text/javascript" src="bower_components/angular-fixed-table-header/src/fixed-table-header.min.js"></script>
Include the fixed.table.header
module as a dependency in your application.
angular.module('myApp', ['fixed.table.header']);
Using npm and Browserify (or JSPM)
In addition, this package may be installed using npm.
npm install angular-fixed-table-header --save
You may use Browserify to inject this module into your application.
angular.module('myApp', [require('angular-fixed-table-header')]);
Floating Labels (angular-directive-implementing-float-label-pattern)
<div class="form-group floating-label-wrapper">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email" ng-model="user.email" with-floating-label>
</div>
<div class="form-group floating-label-wrapper">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" ng-model="user.password" with-floating-label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
app.directive('withFloatingLabel', function () {
return {
restrict: 'A',
link: function ($scope, $element, attrs) {
var template = '<div class="floating-label">' + attrs.placeholder +'</div>'
//append floating label template
$element.after(template);
//remove placeholder
$element.removeAttr('placeholder');
//hide label tag assotiated with given input
document.querySelector('label[for="' + attrs.id + '"]').style.display = 'none'
$scope.$watch(function () {
if($element.val().toString().length < 1) {
$element.addClass('empty';
} else {
$element.removeClass('empty');
}
});
}
};
});
.well {
margin: 10px;
}
.well input {
margin-bottom: 20px;
}
.floating-label-wrapper {
position: relative;
}
.floating-label {
color: #7E7E7E;
font-size: 14px;
position: absolute;
pointer-events: none;
left: 12px;
top: 7px;
transition: 0.2s ease all;
opacity: 0;
}
.form-control:focus ~ .floating-label,
.form-control:not(.empty) ~ .floating-label {
top: -15px;
left: 0;
font-size: 11px;
opacity: 1;
}
.form-control.empty ~ .floating-label {
opacity: 1;
}
textarea { resize: none; }
textarea ~ .form-control-highlight {
margin-top: -11px;
}
Modals (ui.bootstrap.modal)
$uibModal
is a service to create modal windows.
Creating modals is straightforward: create a template and controller, and reference them when using $uibModal
.
The $uibModal
service has only one method: open(options)
.
<div ng-controller="ModalDemoCtrl as $ctrl" class="modal-demo">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body" id="modal-body">
<ul>
<li ng-repeat="item in $ctrl.items">
<a href="#" ng-click="$event.preventDefault(); $ctrl.selected.item = item">{{ item }}</a>
</li>
</ul>
Selected: <b>{{ $ctrl.selected.item }}</b>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="$ctrl.ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="$ctrl.cancel()">Cancel</button>
</div>
</script>
<script type="text/ng-template" id="stackedModal.html">
<div class="modal-header">
<h3 class="modal-title" id="modal-title-{{name}}">The {{name}} modal!</h3>
</div>
<div class="modal-body" id="modal-body-{{name}}">
Having multiple modals open at once is probably bad UX but it's technically possible.
</div>
</script>
<button type="button" class="btn btn-default" ng-click="$ctrl.open()">Open me!</button>
<button type="button" class="btn btn-default" ng-click="$ctrl.open('lg')">Large modal</button>
<button type="button" class="btn btn-default" ng-click="$ctrl.open('sm')">Small modal</button>
<button type="button"
class="btn btn-default"
ng-click="$ctrl.open('sm', '.modal-parent')">
Modal appended to a custom parent
</button>
<button type="button" class="btn btn-default" ng-click="$ctrl.toggleAnimation()">Toggle Animation ({{ $ctrl.animationsEnabled }})</button>
<button type="button" class="btn btn-default" ng-click="$ctrl.openComponentModal()">Open a component modal!</button>
<button type="button" class="btn btn-default" ng-click="$ctrl.openMultipleModals()">
Open multiple modals at once
</button>
<div ng-show="$ctrl.selected">Selection from a modal: {{ $ctrl.selected }}</div>
<div class="modal-parent">
</div>
</div>
app.controller('ModalDemoCtrl', function ($uibModal, $log, $document) {
var $ctrl = this;
$ctrl.items = ['item1', 'item2', 'item3'];
$ctrl.animationsEnabled = true;
$ctrl.open = function (size, parentSelector) {
var parentElem = parentSelector ?
angular.element($document[0].querySelector('.modal-demo ' + parentSelector)) : undefined;
var modalInstance = $uibModal.open({
animation: $ctrl.animationsEnabled,
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
controllerAs: '$ctrl',
size: size,
appendTo: parentElem,
resolve: {
items: function () {
return $ctrl.items;
}
}
});
modalInstance.result.then(function (selectedItem) {
$ctrl.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
$ctrl.openComponentModal = function () {
var modalInstance = $uibModal.open({
animation: $ctrl.animationsEnabled,
component: 'modalComponent',
resolve: {
items: function () {
return $ctrl.items;
}
}
});
modalInstance.result.then(function (selectedItem) {
$ctrl.selected = selectedItem;
}, function () {
$log.info('modal-component dismissed at: ' + new Date());
});
};
$ctrl.openMultipleModals = function () {
$uibModal.open({
animation: $ctrl.animationsEnabled,
ariaLabelledBy: 'modal-title-bottom',
ariaDescribedBy: 'modal-body-bottom',
templateUrl: 'stackedModal.html',
size: 'sm',
controller: function($scope) {
$scope.name = 'bottom';
}
});
$uibModal.open({
animation: $ctrl.animationsEnabled,
ariaLabelledBy: 'modal-title-top',
ariaDescribedBy: 'modal-body-top',
templateUrl: 'stackedModal.html',
size: 'sm',
controller: function($scope) {
$scope.name = 'top';
}
});
};
$ctrl.toggleAnimation = function () {
$ctrl.animationsEnabled = !$ctrl.animationsEnabled;
};
});
// Please note that $uibModalInstance represents a modal window (instance) dependency.
// It is not the same as the $uibModal service used above.
app.controller('ModalInstanceCtrl', function ($uibModalInstance, items) {
var $ctrl = this;
$ctrl.items = items;
$ctrl.selected = {
item: $ctrl.items[0]
};
$ctrl.ok = function () {
$uibModalInstance.close($ctrl.selected.item);
};
$ctrl.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
});
// Please note that the close and dismiss bindings are from $uibModalInstance.
app.component('modalComponent', {
templateUrl: 'myModalContent.html',
bindings: {
resolve: '<',
close: '&',
dismiss: '&'
},
controller: function () {
var $ctrl = this;
$ctrl.$onInit = function () {
$ctrl.items = $ctrl.resolve.items;
$ctrl.selected = {
item: $ctrl.items[0]
};
};
$ctrl.ok = function () {
$ctrl.close({$value: $ctrl.selected.item});
};
$ctrl.cancel = function () {
$ctrl.dismiss({$value: 'cancel'});
};
}
});
$uibModal's open function
options parameter
animation
(Type:boolean
, Default:true
) - Set to false to disable animations on new modal/backdrop. Does not toggle animations for modals/backdrops that are already displayed.appendTo
(Type:angular.element
, Default:body
: Example:$document.find('aside').eq(0)
) - Appends the modal to a specific element.ariaDescribedBy
(Type:string
,my-modal-description
) - Sets thearia-describedby
property on the modal. The value should be an id (without the leading#
) pointing to the element that describes your modal. Typically, this will be the text on your modal, but does not include something the user would interact with, like buttons or a form. Omitting this option will not impact sighted users but will weaken your accessibility support.ariaLabelledBy
(Type:string
,my-modal-title
) - Sets thearia-labelledby
property on the modal. The value should be an id (without the leading#
) pointing to the element that labels your modal. Typically, this will be a header element. Omitting this option will not impact sighted users but will weaken your accessibility support.backdrop
(Type:boolean|string
, Default:true
) - Controls presence of a backdrop. Allowed values:true
(default),false
(no backdrop),'static'
(disables modal closing by click on the backdrop).backdropClass
(Type:string
) - Additional CSS class(es) to be added to a modal backdrop template.bindToController
(Type:boolean
, Default:false
) - When used withcontrollerAs
& set totrue
, it will bind the $scope properties onto the controller.component
(Type:string
, Example:myComponent
) - A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must haverestrict: 'E'
and a template or templateUrl set.It supports these bindings:
close
- A method that can be used to close a modal, passing a result. The result must be passed in this format:{$value: myResult}
dismiss
- A method that can be used to dismiss a modal, passing a result. The result must be passed in this format:{$value: myRejectedResult}
modalInstance
- The modal instance. This is the same$uibModalInstance
injectable found when usingcontroller
.resolve
- An object of the modal resolve values. See UI Router resolves for details.
controller
(Type:function|string|array
, Example:MyModalController
) - A controller for the modal instance, either a controller name as a string, or an inline controller function, optionally wrapped in array notation for dependency injection. Allows the controller-as syntax. Has a special$uibModalInstance
injectable to access the modal instance.controllerAs
(Type:string
, Example:ctrl
) - An alternative to the controller-as syntax. Requires thecontroller
option to be provided as well.keyboard
- (Type:boolean
, Default:true
) - Indicates whether the dialog should be closable by hitting the ESC key.openedClass
(Type:string
, Default:modal-open
) - Class added to thebody
element when the modal is opened.resolve
(Type:Object
) - Members that will be resolved and passed to the controller as locals; it is equivalent of theresolve
property in the router.scope
(Type:$scope
) - The parent scope instance to be used for the modal's content. Defaults to$rootScope
.size
(Type:string
, Example:lg
) - Optional suffix of modal window class. The value used is appended to themodal-
class, i.e. a value ofsm
givesmodal-sm
.template
(Type:string
) - Inline template representing the modal's content.templateUrl
(Type:string
) - A path to a template representing modal's content. You need either atemplate
ortemplateUrl
.windowClass
(Type:string
) - Additional CSS class(es) to be added to a modal window template.windowTemplateUrl
(Type:string
, Default:uib/template/modal/window.html
) - A path to a template overriding modal's window template.windowTopClass
(Type:string
) - CSS class(es) to be added to the top modal window.
Global defaults may be set for $uibModal
via $uibModalProvider.options
.
return
The open
method returns a modal instance, an object with the following properties:
close(result)
(Type:function
) - Can be used to close a modal, passing a result.dismiss(reason)
(Type:function
) - Can be used to dismiss a modal, passing a reason.result
(Type:promise
) - Is resolved when a modal is closed and rejected when a modal is dismissed.opened
(Type:promise
) - Is resolved when a modal gets opened after downloading content's template and resolving all variables.closed
(Type:promise
) - Is resolved when a modal is closed and the animation completes.rendered
(Type:promise
) - Is resolved when a modal is rendered.
The scope associated with modal's content is augmented with:
$close(result)
(Type:function
) - A method that can be used to close a modal, passing a result.$dismiss(reason)
(Type:function
) - A method that can be used to dismiss a modal, passing a reason.
Those methods make it easy to close a modal window without a need to create a dedicated controller.
Also, when using bindToController
, you can define an $onInit
method in the controller that will fire upon initialization.
Events fired:
$uibUnscheduledDestruction
- This event is fired if the $scope is destroyed via unexpected mechanism, such as it being passed in the modal options and a $route/$state transition occurs. The modal will also be dismissed.modal.closing
- This event is broadcast to the modal scope before the modal closes. If the listener calls preventDefault() on the event, then the modal will remain open. Also, the$close
and$dismiss
methods returns true if the event was executed. This event also includes a parameter for the result/reason and a boolean that indicates whether the modal is being closed (true) or dismissed.
UI Router resolves
If one wants to have the modal resolve using UI Router's pre-1.0 resolve mechanism, one can call $uibResolve.setResolver('$resolve')
in the configuration phase of the application. One can also provide a custom resolver as well, as long as the signature conforms to UI Router's $resolve.
When the modal is opened with a controller, a $resolve
object is exposed on the template with the resolved values from the resolve object. If using the component option, see details on how to access this object in component section of the modal documentation.
Ng-Table (ng-table)
ngTable
provides a header template that adds grouping to a html table. To configure a table for groups:
- Markup your html table as per the example below
- Specify which column should be groupable
ngTable
- specify this in the html markupngTableDynamic
- specify this in the JS column definitions
- Supply the initial column to group on to the
NgTableParams
constructor call - Optionally supply
groupOptions
as a setting value to theNgTableParams
Got a getData
function?
In this case be aware that paging of data will be applied after the call to your getData
function. This might be a problem where your getData
returns large number of records.
[[ group.value ]] | |||
[[user.country]] | [[user.name]] | [[user.age]] | [[user.money]] |
<table ng-table="usersTable" class="table table-condensed table-bordered table-hover">
<colgroup>
<col width="60%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<tr class="ng-table-group" ng-repeat-start="group in $groups">
<td colspan="3">
<a href="" ng-click="group.$hideRows = !group.$hideRows">
<span class="glyphicon" ng-class="{ 'glyphicon-chevron-right': group.$hideRows, 'glyphicon-chevron-down': !group.$hideRows }"></span>
<strong>{{ group.value }}</strong>
</a>
</td>
</tr>
<tr ng-hide="group.$hideRows" ng-repeat="user in group.data" ng-repeat-end>
<td sortable="'country'" data-title="'Country'" groupable="'country'" ng-if="false">
{{user.country}}
</td>
<td sortable="'name'" data-title="'Name'" groupable="'name'">
{{user.name}}
</td>
<td sortable="'age'" data-title="'Age'" groupable="'age'">
{{user.age}}
</td>
<td sortable="'money'" data-title="'Money'">
{{user.money}}
</td>
</tr>
</table>
angular.module('mineralbay').controller('tableController', ['$scope','$http', 'NgTableParams', function ($scope, $http, NgTableParams) {
$scope.users = [{"name":"Karen","age":45,"money":798,"country":"Czech Republic"},
{"name":"Cat","age":49,"money":749,"country":"Czech Republic"},
{"name":"Bismark","age":48,"money":672,"country":"Denmark"},
{"name":"Markus","age":41,"money":695,"country":"Costa Rica"},
{"name":"Anthony","age":45,"money":559,"country":"Japan"},
{"name":"Alex","age":55,"money":645,"country":"Czech Republic"},
{"name":"Stephane","age":57,"money":662,"country":"Japan"},
{"name":"Alex","age":59,"money":523,"country":"American Samoa"},
{"name":"Tony","age":56,"money":540,"country":"Canada"},
{"name":"Cat","age":57,"money":746,"country":"China"},
{"name":"Christian","age":59,"money":572,"country":"Canada"},
{"name":"Tony","age":60,"money":649,"country":"Japan"},
{"name":"Cat","age":47,"money":675,"country":"Denmark"},
{"name":"Stephane","age":50,"money":674,"country":"China"},
{"name":"Markus","age":40,"money":549,"country":"Portugal"},
{"name":"Anthony","age":53,"money":660,"country":"Bahamas"},
{"name":"Stephane","age":54,"money":549,"country":"China"},
{"name":"Karen","age":50,"money":611,"country":"American Samoa"},
{"name":"Therese","age":53,"money":754,"country":"China"},
{"name":"Bismark","age":49,"money":791,"country":"Canada"},
{"name":"Daraek","age":56,"money":640,"country":"Costa Rica"},
{"name":"Tony","age":43,"money":674,"country":"Canada"},
{"name":"Karen","age":47,"money":700,"country":"Portugal"},
{"name":"Therese","age":47,"money":718,"country":"Czech Republic"},
{"name":"Karen","age":50,"money":655,"country":"Japan"},
{"name":"Daraek","age":59,"money":581,"country":"American Samoa"},
{"name":"Daraek","age":60,"money":595,"country":"Portugal"},
{"name":"Markus","age":44,"money":607,"country":"China"},
{"name":"Simon","age":58,"money":728,"country":"Japan"},
{"name":"Simon","age":49,"money":655,"country":"Bahamas"}];
$scope.usersTable = new NgTableParams({
// initial grouping
group: {
country: "desc"
}
}, {
dataset: $scope.users,
groupOptions: {
isExpanded: true
}
});
}]);
Pager (ui.bootstrap.pager)
A lightweight pager directive that is focused on providing previous/next paging functionality
Pager
You are currently on page [[currentPage]]
<div ng-controller="PagerDemoCtrl">
<h4>Pager</h4>
<pre>You are currently on page {{currentPage}}</pre>
<ul uib-pager total-items="totalItems" ng-model="currentPage"></ul>
</div>
app.controller('PagerDemoCtrl', function($scope) {
$scope.totalItems = 64;
$scope.currentPage = 4;
});
uib-pager settings
align
C (Default:true
) - Whether to align each link to the sides.items-per-page
$ C (Default:10
) - Maximum number of items per page. A value less than one indicates all items on one page.next-text
C (Default:Next »
) - Text for Next button.ng-disabled
$ (Default:false
) - Used to disable the pager component.ng-model
$ - Current page number. First page is 1.num-pages
$ readonly (Default:angular.noop
) - An optional expression assigned the total number of pages to display.previous-text
C (Default:« Previous
) - Text for Previous button.template-url
(Default:uib/template/pager/pager.html
) - Override the template for the component with a custom provided template.total-items
$ - Total number of items in all pages.
Pagination (ui.bootstrap.pagination)
Default
The selected page no:
Limit the maximum visible buttons
rotate
defaulted to true
:
rotate
defaulted to true
and force-ellipses
set to true
:
rotate
set to false
:
boundary-link-numbers
set to true
and rotate
defaulted to true
:
boundary-link-numbers
set to true
and rotate
set to false
:
Page: /
<h4>Default</h4>
<ul uib-pagination total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()"></ul></br>
<ul uib-pagination boundary-links="true" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="‹" next-text="›" first-text="«" last-text="»"></ul></br>
<ul uib-pagination direction-links="false" boundary-links="true" total-items="totalItems" ng-model="currentPage"></ul></br>
<ul uib-pagination direction-links="false" total-items="totalItems" ng-model="currentPage" num-pages="smallnumPages"></ul>
<pre>The selected page no: <span ng-bind="currentPage"></span></pre>
<button type="button" class="btn btn-info" ng-click="setPage(3)">Set current page to: 3</button>
<hr />
<h4>Limit the maximum visible buttons</h4>
<h6><code>rotate</code> defaulted to <code>true</code>:</h6>
<ul uib-pagination total-items="bigTotalItems" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" num-pages="numPages"></ul>
<h6><code>rotate</code> defaulted to <code>true</code> and <code>force-ellipses</code> set to <code>true</code>:</h6>
<ul uib-pagination total-items="bigTotalItems" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" force-ellipses="true"></ul>
<h6><code>rotate</code> set to <code>false</code>:</h6>
<ul uib-pagination total-items="bigTotalItems" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" rotate="false"></ul>
<h6><code>boundary-link-numbers</code> set to <code>true</code> and <code>rotate</code> defaulted to <code>true</code>:</h6>
<ul uib-pagination total-items="bigTotalItems" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-link-numbers="true"></ul>
<h6><code>boundary-link-numbers</code> set to <code>true</code> and <code>rotate</code> set to <code>false</code>:</h6>
<ul uib-pagination total-items="bigTotalItems" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-link-numbers="true" rotate="false"></ul>
<pre>Page:<span ng-bind="bigCurrentPage"></span> / <span ng-bind="numPages"></span></pre>
app.controller('PaginationDemoCtrl', function ($scope, $log) {
$scope.totalItems = 64;
$scope.currentPage = 4;
$scope.setPage = function (pageNo) {
$scope.currentPage = pageNo;
};
$scope.pageChanged = function() {
$log.log('Page changed to: ' + $scope.currentPage);
};
$scope.maxSize = 5;
$scope.bigTotalItems = 175;
$scope.bigCurrentPage = 1;
});
.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover,
.pagination > .active > span:hover,
.pagination > .active > a:focus,
.pagination > .active > span:focus {
z-index: 2;
color: #fff;
background-color: #ee6023;
border-color: #ee6023;
cursor: default;
}
uib-pagination settings
boundary-links
C (Default:false
) - Whether to display First / Last buttons.boundary-link-numbers
$ C (Default:false
) - Whether to always display the first and last page numbers. Ifmax-size
is smaller than the number of pages, then the first and last page numbers are still shown with ellipses in-between as necessary. NOTE:max-size
refers to the center of the range. This option may add up to 2 more numbers on each side of the displayed range for the end value and what would be an ellipsis but is replaced by a number because it is sequential.direction-links
$ C (Default:true
) - Whether to display Previous / Next buttons.first-text
C (Default:First
) - Text for First button.force-ellipses
$ C (Default:false
) - Also displays ellipses whenrotate
is true andmax-size
is smaller than the number of pages.items-per-page
$ C (Default:10
) - Maximum number of items per page. A value less than one indicates all items on one page.last-text
C (Default:Last
) - Text for Last button.max-size
$ (Default:null
) - Limit number for pagination size.next-text
C (Default:Next
) - Text for Next button.ng-change
$ - This can be used to call a function whenever the page changes.ng-disabled
$ (Default:false
) - Used to disable the pagination component.ng-model
$ - Current page number. First page is 1.num-pages
$ readonly (Default:angular.noop
) - An optional expression assigned the total number of pages to display.page-label
(Default:angular.identity
) - An optional expression to override the page label based on passing the current page indexes. Supports page number with$page
in the template.previous-text
C (Default:Previous
) - Text for Previous button.rotate
$ C (Default:true
) - Whether to keep current page in the middle of the visible ones.template-url
(Default:uib/template/pagination/pagination.html
) - Override the template for the component with a custom provided templatetotal-items
$ - Total number of items in all pages.
Popover (ui.bootstrap.popover)
Like the Bootstrap jQuery plugin, the popover requires the tooltip module.
Note to mobile developers: Please note that while popovers may work correctly on mobile devices (including tablets), we have made the decision to not officially support such a use-case because it does not make sense from a UX perspective.
There are three versions of the popover: uib-popover
and uib-popover-template
, and uib-popover-html
:
uib-popover
- Takes text only and will escape any HTML provided for the popover body.uib-popover-html
$ - Takes an expression that evaluates to an HTML string. Note that this HTML is not compiled. If compilation is required, please use theuib-popover-template
attribute option instead. The user is responsible for ensuring the content is safe to put into the DOM!uib-popover-template
$ - A URL representing the location of a template to use for the popover body. Note that the contents of this template need to be wrapped in a tag, e.g.,<div></div>
.
Dynamic
Positional
Triggers
Other
<div ng-controller="PopoverDemoCtrl">
<h4>Dynamic</h4>
<div class="form-group">
<label>Popup Text:</label>
<input type="text" ng-model="dynamicPopover.content" class="form-control">
</div>
<div class="form-group">
<label>Popup Title:</label>
<input type="text" ng-model="dynamicPopover.title" class="form-control">
</div>
<div class="form-group">
<label>Popup Template:</label>
<input type="text" ng-model="dynamicPopover.templateUrl" class="form-control">
</div>
<button uib-popover="{{dynamicPopover.content}}" popover-title="{{dynamicPopover.title}}" type="button" class="btn btn-default">Dynamic Popover</button>
<button uib-popover-template="dynamicPopover.templateUrl" popover-title="{{dynamicPopover.title}}" type="button" class="btn btn-default">Popover With Template</button>
<script type="text/ng-template" id="myPopoverTemplate.html">
<div>{{dynamicPopover.content}}</div>
<div class="form-group">
<label>Popup Title:</label>
<input type="text" ng-model="dynamicPopover.title" class="form-control">
</div>
</script>
<hr />
<h4>Positional</h4>
<div class="form-group">
<label>Popover placement</label>
<select class="form-control" ng-model="placement.selected" ng-options="o as o for o in placement.options"></select>
</div>
<button popover-placement="{{placement.selected}}" uib-popover="On the {{placement.selected}}" type="button" class="btn btn-default">Popover {{placement.selected}}</button>
<hr />
<h4>Triggers</h4>
<p>
<button uib-popover="I appeared on mouse enter!" popover-trigger="'mouseenter'" type="button" class="btn btn-default">Mouseenter</button>
</p>
<input type="text" value="Click me!" uib-popover="I appeared on focus! Click away and I'll vanish..." popover-trigger="'focus'" class="form-control">
<hr />
<h4>Other</h4>
<button popover-animation="true" uib-popover="I fade in and out!" type="button" class="btn btn-default">fading</button>
<button uib-popover="I have a title!" popover-title="The title." type="button" class="btn btn-default">title</button>
<button uib-popover="I am activated manually" popover-is-open="popoverIsOpen" ng-click="popoverIsOpen = !popoverIsOpen" type="button" class="btn btn-default">Toggle popover</button>
<button uib-popover-html="htmlPopover" class="btn btn-default">HTML Popover</button>
<button uib-popover-html="'<b>HTML</b>, <i>inline</i>'" class="btn btn-default">HTML Popover (inline)</button>
</div>
angular.module('ui.bootstrap.demo').controller('PopoverDemoCtrl', function ($scope, $sce) {
$scope.dynamicPopover = {
content: 'Hello, World!',
templateUrl: 'myPopoverTemplate.html',
title: 'Title'
};
$scope.placement = {
options: [
'top',
'top-left',
'top-right',
'bottom',
'bottom-left',
'bottom-right',
'left',
'left-top',
'left-bottom',
'right',
'right-top',
'right-bottom'
],
selected: 'top'
};
$scope.htmlPopover = $sce.trustAsHtml('<b style="color: red">I can</b> have <div class="label label-success">HTML</div> content');
});
uib-popover-* settings
All these settings are available for the three types of popovers.
popover-animation
$ C (Default:true
, Config:animation
) - Should it fade in and out?popover-append-to-body
$ C (Default:false
, Config:appendToBody
) - Should the popover be appended to '$body' instead of the parent element?popover-class
- Custom class to be applied to the popover.popover-enable
$ (Default:true
) - Is it enabled? It will enable or disable the configured popover-trigger.popover-is-open
(Default:false
) - Whether to show the popover.popover-placement
C (Default:top
, Config:placement
) - Passing in 'auto' separated by a space before the placement will enable auto positioning, e.g: "auto bottom-left". The popover will attempt to position where it fits in the closest scrollable ancestor. Accepts:top
- popover on top, horizontally centered on host element.top-left
- popover on top, left edge aligned with host element left edge.top-right
- popover on top, right edge aligned with host element right edge.bottom
- popover on bottom, horizontally centered on host element.bottom-left
- popover on bottom, left edge aligned with host element left edge.bottom-right
- popover on bottom, right edge aligned with host element right edge.left
- popover on left, vertically centered on host element.left-top
- popover on left, top edge aligned with host element top edge.left-bottom
- popover on left, bottom edge aligned with host element bottom edge.right
- popover on right, vertically centered on host element.right-top
- popover on right, top edge aligned with host element top edge.right-bottom
- popover on right, bottom edge aligned with host element bottom edge.
popover-popup-close-delay
C (Default:0
, Config:popupCloseDelay
) - For how long should the popover remain open after the close trigger event?popover-popup-delay
C (Default:0
, Config:popupDelay
) - Popup delay in milliseconds until it opens.popover-title
- A string to display as a fancy title.popover-trigger
$ (Default:'click'
) - What should trigger a show of the popover? Supports a space separated list of event names, or objects (see below).
Note: To configure the tooltips, you need to do it on $uibTooltipProvider
(also see below).
Triggers
The following show triggers are supported out of the box, along with their provided hide triggers:
mouseenter
:mouseleave
click
:click
outsideClick
:outsideClick
focus
:blur
none
The outsideClick
trigger will cause the popover to toggle on click, and hide when anything else is clicked.
For any non-supported value, the trigger will be used to both show and hide the
popover. Using the 'none' trigger will disable the internal trigger(s), one can
then use the popover-is-open
attribute exclusively to show and hide the popover.
$uibTooltipProvider
Through the $uibTooltipProvider
, you can change the way tooltips and popovers
behave by default; the attributes above always take precedence. The following
methods are available:
setTriggers(obj)
(Example:{ 'openTrigger': 'closeTrigger' }
) - Extends the default trigger mappings mentioned above with mappings of your own.options(obj)
- Provide a set of defaults for certain tooltip and popover attributes. Currently supports the ones with the C badge.
Known issues
For Safari 7+ support, if you want to use focus popover-trigger
, you need to use an anchor tag with a tab index. For example:
<a tabindex="0" uib-popover="Test" popover-trigger="focus" class="btn btn-default">
Click Me
</a>
Progressbar (ui.bootstrap.progressbar)
The UIB-Progressbar supports multiple (stacked) <uib-bar>
into the same <uib-progress>
element or a single <uib-progressbar>
element with optional max
attribute and transition animations.
Static
Dynamic
Stacked
<div ng-controller="ProgressDemoCtrl">
<h3>Static</h3>
<div class="row">
<div class="col-sm-4"><uib-progressbar value="55"></uib-progressbar></div>
<div class="col-sm-4"><uib-progressbar class="progress-striped" value="22" type="warning">22%</uib-progressbar></div>
<div class="col-sm-4"><uib-progressbar class="progress-striped active" max="200" value="166" type="danger"><i>166 / 200</i></uib-progressbar></div>
</div>
<hr />
<h3>Dynamic <button type="button" class="btn btn-sm btn-primary" ng-click="random()">Randomize</button></h3>
<uib-progressbar max="max" value="dynamic"><span style="color:white; white-space:nowrap;">{{dynamic}} / {{max}}</span></uib-progressbar>
<small><em>No animation</em></small>
<uib-progressbar animate="false" value="dynamic" type="success"><b>{{dynamic}}%</b></uib-progressbar>
<small><em>Object (changes type based on value)</em></small>
<uib-progressbar class="progress-striped active" value="dynamic" type="{{type}}">{{type}} <i ng-show="showWarning">!!! Watch out !!!</i></uib-progressbar>
<hr />
<h3>Stacked <button type="button" class="btn btn-sm btn-primary" ng-click="randomStacked()">Randomize</button></h3>
<uib-progress><uib-bar ng-repeat="bar in stacked track by $index" value="bar.value" type="{{bar.type}}"><span ng-hide="bar.value < 5">{{bar.value}}%</span></uib-bar></uib-progress>
</div>
angular.module('mineralbay').controller('ProgressDemoCtrl', function ($scope) {
$scope.max = 200;
$scope.random = function() {
var value = Math.floor(Math.random() * 100 + 1);
var type;
if (value < 25) {
type = 'success';
} else if (value < 50) {
type = 'info';
} else if (value < 75) {
type = 'warning';
} else {
type = 'danger';
}
$scope.showWarning = type === 'danger' || type === 'warning';
$scope.dynamic = value;
$scope.type = type;
};
$scope.random();
$scope.randomStacked = function() {
$scope.stacked = [];
var types = ['success', 'info', 'warning', 'danger'];
for (var i = 0, n = Math.floor(Math.random() * 4 + 1); i < n; i++) {
var index = Math.floor(Math.random() * 4);
$scope.stacked.push({
value: Math.floor(Math.random() * 30 + 1),
type: types[index]
});
}
};
$scope.randomStacked();
});
uib-progressbar settings
value
$ - The current value of progress completed.type
(Default:null
) - Bootstrap style type. Possible values are 'success', 'info', 'warning', and, 'danger' to use Bootstrap's pre-existing styling, or any desired custom suffix.max
$ C (Default:100
) - A number that specifies the total value of bars that is required.animate
$ C (Default:true
) - Whether bars use transitions to achieve the width change.title
(Default:progressbar
) - Title to use as label (for accessibility).
uib-progress settings
max
$ C (Default:100
) - A number that specifies the total value of bars that is required.animate
$ C (Default:true
) - Whether bars use transitions to achieve the width change.title
(Default:progressbar
) - Title to use as label (for accessibility).
uib-bar settings
value
$ - The current value of progress completed.type
(Default:null
) - Bootstrap style type. Possible values are 'success', 'info', 'warning', and, 'danger' to use Bootstrap's pre-existing styling, or any desired custom suffix.title
(Default:progressbar
) - Title to use as label (for accessibility).
Select (ui.select, AngularStrap)
<!-- ui-select inside a Bootstrap form -->
<p>Selected: {{person.selected.name}}</p>
<div class="form-group">
<label class="col-sm-3 control-label">Default</label>
<div class="col-sm-6">
<ui-select ng-model="person.selected" theme="bootstrap">
<ui-select-match placeholder="Select or search a person in the list..." class="ui-select-match">{{$select.selected.name}}</ui-select-match>
<ui-select-choices class="ui-select-choices" repeat="item in people | filter: $select.search">
<div ng-bind-html="item.name | highlight: $select.search"></div>
<small ng-bind-html="item.email | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Grouped</label>
<div class="col-sm-6">
<ui-select ng-model="person.selected">
<ui-select-match class="ui-select-match" placeholder="Select or search a person in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices class="ui-select-choices" group-by="'country'" repeat="item in people | filter: $select.search">
<span ng-bind-html="item.name | highlight: $select.search"></span>
<small ng-bind-html="item.email | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">With a clear button</label>
<div class="col-sm-6">
<div class="input-group">
<ui-select ng-model="person.selected" theme="bootstrap">
<ui-select-match placeholder="Select or search a person in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="item in people | filter: $select.search">
<span ng-bind-html="item.name | highlight: $select.search"></span>
<small ng-bind-html="item.email | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
<span class="input-group-btn">
<button ng-click="person.selected = undefined" class="btn btn-default">
<span class="glyphicon glyphicon-trash"></span>
</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Disabled</label>
<div class="col-sm-6">
<ui-select ng-model="person.selected" theme="bootstrap" ng-disabled="true">
<ui-select-match class="ui-select-match" placeholder="Select or search a person in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices class="ui-select-choices" repeat="item in people | filter: $select.search">
<div ng-bind-html="item.name | highlight: $select.search"></div>
<small ng-bind-html="item.email | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Multiple Select - Array of objects (sorting enabled)</label>
<div class="col-sm-6">
<ui-select multiple ng-model="multipleDemo.selectedPeople" theme="bootstrap" ng-disabled="disabled" sortable="true" close-on-select="false">
<ui-select-match placeholder="Select person...">{{$item.name}} <{{$item.email}}></ui-select-match>
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
<div ng-bind-html="person.name | highlight: $select.search"></div>
<small>
email: {{person.email}}
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
</small>
</ui-select-choices>
</ui-select>
<p>Selected: {{multipleDemo.selectedPeople}}</p>
</div>
</div>
<legend>AngularStrap select</legend>
<!-- AngularStrap select -->
<div class="form-group">
<label class="col-sm-3 control-label">Single select: </label>
<div class="col-sm-6">
<button type="button" class="btn btn-default" ng-model="selectedIcon" data-html="1" bs-options="icon.value as icon.label for icon in icons" bs-select> Action <span class="caret"></span>
</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Multiple select: </label>
<div class="col-sm-6">
<button type="button" class="btn btn-default" ng-model="selectedIcons" data-html="1" data-multiple="1" data-animation="am-flip-x" bs-options="icon.value as icon.label for icon in icons" bs-select> Action <span class="caret"></span>
</button>
</div>
</div>
angular.module('mineralbay').filter('propsFilter', function() {
return function(items, props) {
var out = [];
if (angular.isArray(items)) {
items.forEach(function(item) {
var itemMatches = false;
var keys = Object.keys(props);
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
itemMatches = true;
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
// Let the output be the input untouched
out = items;
}
return out;
};
});
angular.module('mineralbay').controller('DemoCtrl', function($scope, $http, $timeout) {
$scope.disabled = undefined;
$scope.searchEnabled = undefined;
$scope.enable = function() {
$scope.disabled = false;
};
$scope.disable = function() {
$scope.disabled = true;
};
$scope.enableSearch = function() {
$scope.searchEnabled = true;
}
$scope.disableSearch = function() {
$scope.searchEnabled = false;
}
$scope.clear = function() {
$scope.person.selected = undefined;
$scope.address.selected = undefined;
$scope.country.selected = undefined;
};
$scope.someGroupFn = function (item){
if (item.name[0] >= 'A' && item.name[0] <= 'M')
return 'From A - M';
if (item.name[0] >= 'N' && item.name[0] <= 'Z')
return 'From N - Z';
};
$scope.firstLetterGroupFn = function (item){
return item.name[0];
};
$scope.reverseOrderFilterFn = function(groups) {
return groups.reverse();
};
$scope.personAsync = {selected : "wladimir@email.com"};
$scope.peopleAsync = [];
$timeout(function(){
$scope.peopleAsync = [
{ name: 'Adam', email: 'adam@email.com', age: 12, country: 'United States' },
{ name: 'Amalie', email: 'amalie@email.com', age: 12, country: 'Argentina' },
{ name: 'Estefanía', email: 'estefania@email.com', age: 21, country: 'Argentina' },
{ name: 'Adrian', email: 'adrian@email.com', age: 21, country: 'Ecuador' },
{ name: 'Wladimir', email: 'wladimir@email.com', age: 30, country: 'Ecuador' },
{ name: 'Samantha', email: 'samantha@email.com', age: 30, country: 'United States' },
{ name: 'Nicole', email: 'nicole@email.com', age: 43, country: 'Colombia' },
{ name: 'Natasha', email: 'natasha@email.com', age: 54, country: 'Ecuador' },
{ name: 'Michael', email: 'michael@email.com', age: 15, country: 'Colombia' },
{ name: 'Nicolás', email: 'nicole@email.com', age: 43, country: 'Colombia' }
];
},3000);
$scope.counter = 0;
$scope.someFunction = function (item, model){
$scope.counter++;
$scope.eventResult = {item: item, model: model};
};
$scope.person = {};
$scope.people = [
{ name: 'Adam', email: 'adam@email.com', age: 12, country: 'United States' },
{ name: 'Amalie', email: 'amalie@email.com', age: 12, country: 'Argentina' },
{ name: 'Estefanía', email: 'estefania@email.com', age: 21, country: 'Argentina' },
{ name: 'Adrian', email: 'adrian@email.com', age: 21, country: 'Ecuador' },
{ name: 'Wladimir', email: 'wladimir@email.com', age: 30, country: 'Ecuador' },
{ name: 'Samantha', email: 'samantha@email.com', age: 30, country: 'United States' },
{ name: 'Nicole', email: 'nicole@email.com', age: 43, country: 'Colombia' },
{ name: 'Natasha', email: 'natasha@email.com', age: 54, country: 'Ecuador' },
{ name: 'Michael', email: 'michael@email.com', age: 15, country: 'Colombia' },
{ name: 'Nicolás', email: 'nicolas@email.com', age: 43, country: 'Colombia' }
];
$scope.availableColors = ['Red','Green','Blue','Yellow','Magenta','Maroon','Umbra','Turquoise'];
$scope.multipleDemo = {};
$scope.multipleDemo.colors = ['Blue','Red'];
$scope.multipleDemo.selectedPeople = [$scope.people[5], $scope.people[4]];
$scope.multipleDemo.selectedPeopleWithGroupBy = [$scope.people[8], $scope.people[6]];
$scope.multipleDemo.selectedPeopleSimple = ['samantha@email.com','wladimir@email.com'];
$scope.country = {};
$scope.countries = [ // Taken from https://gist.github.com/unceus/6501985
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'Andorra', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
{name: 'Antigua and Barbuda', code: 'AG'},
{name: 'Argentina', code: 'AR'},
{name: 'Armenia', code: 'AM'},
{name: 'Aruba', code: 'AW'},
{name: 'Australia', code: 'AU'},
{name: 'Austria', code: 'AT'},
{name: 'Azerbaijan', code: 'AZ'},
{name: 'Bahamas', code: 'BS'},
{name: 'Bahrain', code: 'BH'},
{name: 'Bangladesh', code: 'BD'},
{name: 'Barbados', code: 'BB'},
{name: 'Belarus', code: 'BY'},
{name: 'Belgium', code: 'BE'},
{name: 'Belize', code: 'BZ'},
{name: 'Benin', code: 'BJ'},
{name: 'Bermuda', code: 'BM'},
{name: 'Bhutan', code: 'BT'},
{name: 'Bolivia', code: 'BO'},
{name: 'Bosnia and Herzegovina', code: 'BA'},
{name: 'Botswana', code: 'BW'},
{name: 'Bouvet Island', code: 'BV'},
{name: 'Brazil', code: 'BR'},
{name: 'British Indian Ocean Territory', code: 'IO'},
{name: 'Brunei Darussalam', code: 'BN'},
{name: 'Bulgaria', code: 'BG'},
{name: 'Burkina Faso', code: 'BF'},
{name: 'Burundi', code: 'BI'},
{name: 'Cambodia', code: 'KH'},
{name: 'Cameroon', code: 'CM'},
{name: 'Canada', code: 'CA'},
{name: 'Cape Verde', code: 'CV'},
{name: 'Cayman Islands', code: 'KY'},
{name: 'Central African Republic', code: 'CF'},
{name: 'Chad', code: 'TD'},
{name: 'Chile', code: 'CL'},
{name: 'China', code: 'CN'},
{name: 'Christmas Island', code: 'CX'},
{name: 'Cocos (Keeling) Islands', code: 'CC'},
{name: 'Colombia', code: 'CO'},
{name: 'Comoros', code: 'KM'},
{name: 'Congo', code: 'CG'},
{name: 'Congo, The Democratic Republic of the', code: 'CD'},
{name: 'Cook Islands', code: 'CK'},
{name: 'Costa Rica', code: 'CR'},
{name: 'Cote D\'Ivoire', code: 'CI'},
{name: 'Croatia', code: 'HR'},
{name: 'Cuba', code: 'CU'},
{name: 'Cyprus', code: 'CY'},
{name: 'Czech Republic', code: 'CZ'},
{name: 'Denmark', code: 'DK'},
{name: 'Djibouti', code: 'DJ'},
{name: 'Dominica', code: 'DM'},
{name: 'Dominican Republic', code: 'DO'},
{name: 'Ecuador', code: 'EC'},
{name: 'Egypt', code: 'EG'},
{name: 'El Salvador', code: 'SV'},
{name: 'Equatorial Guinea', code: 'GQ'},
{name: 'Eritrea', code: 'ER'},
{name: 'Estonia', code: 'EE'},
{name: 'Ethiopia', code: 'ET'},
{name: 'Falkland Islands (Malvinas)', code: 'FK'},
{name: 'Faroe Islands', code: 'FO'},
{name: 'Fiji', code: 'FJ'},
{name: 'Finland', code: 'FI'},
{name: 'France', code: 'FR'},
{name: 'French Guiana', code: 'GF'},
{name: 'French Polynesia', code: 'PF'},
{name: 'French Southern Territories', code: 'TF'},
{name: 'Gabon', code: 'GA'},
{name: 'Gambia', code: 'GM'},
{name: 'Georgia', code: 'GE'},
{name: 'Germany', code: 'DE'},
{name: 'Ghana', code: 'GH'},
{name: 'Gibraltar', code: 'GI'},
{name: 'Greece', code: 'GR'},
{name: 'Greenland', code: 'GL'},
{name: 'Grenada', code: 'GD'},
{name: 'Guadeloupe', code: 'GP'},
{name: 'Guam', code: 'GU'},
{name: 'Guatemala', code: 'GT'},
{name: 'Guernsey', code: 'GG'},
{name: 'Guinea', code: 'GN'},
{name: 'Guinea-Bissau', code: 'GW'},
{name: 'Guyana', code: 'GY'},
{name: 'Haiti', code: 'HT'},
{name: 'Heard Island and Mcdonald Islands', code: 'HM'},
{name: 'Holy See (Vatican City State)', code: 'VA'},
{name: 'Honduras', code: 'HN'},
{name: 'Hong Kong', code: 'HK'},
{name: 'Hungary', code: 'HU'},
{name: 'Iceland', code: 'IS'},
{name: 'India', code: 'IN'},
{name: 'Indonesia', code: 'ID'},
{name: 'Iran, Islamic Republic Of', code: 'IR'},
{name: 'Iraq', code: 'IQ'},
{name: 'Ireland', code: 'IE'},
{name: 'Isle of Man', code: 'IM'},
{name: 'Israel', code: 'IL'},
{name: 'Italy', code: 'IT'},
{name: 'Jamaica', code: 'JM'},
{name: 'Japan', code: 'JP'},
{name: 'Jersey', code: 'JE'},
{name: 'Jordan', code: 'JO'},
{name: 'Kazakhstan', code: 'KZ'},
{name: 'Kenya', code: 'KE'},
{name: 'Kiribati', code: 'KI'},
{name: 'Korea, Democratic People\'s Republic of', code: 'KP'},
{name: 'Korea, Republic of', code: 'KR'},
{name: 'Kuwait', code: 'KW'},
{name: 'Kyrgyzstan', code: 'KG'},
{name: 'Lao People\'s Democratic Republic', code: 'LA'},
{name: 'Latvia', code: 'LV'},
{name: 'Lebanon', code: 'LB'},
{name: 'Lesotho', code: 'LS'},
{name: 'Liberia', code: 'LR'},
{name: 'Libyan Arab Jamahiriya', code: 'LY'},
{name: 'Liechtenstein', code: 'LI'},
{name: 'Lithuania', code: 'LT'},
{name: 'Luxembourg', code: 'LU'},
{name: 'Macao', code: 'MO'},
{name: 'Macedonia, The Former Yugoslav Republic of', code: 'MK'},
{name: 'Madagascar', code: 'MG'},
{name: 'Malawi', code: 'MW'},
{name: 'Malaysia', code: 'MY'},
{name: 'Maldives', code: 'MV'},
{name: 'Mali', code: 'ML'},
{name: 'Malta', code: 'MT'},
{name: 'Marshall Islands', code: 'MH'},
{name: 'Martinique', code: 'MQ'},
{name: 'Mauritania', code: 'MR'},
{name: 'Mauritius', code: 'MU'},
{name: 'Mayotte', code: 'YT'},
{name: 'Mexico', code: 'MX'},
{name: 'Micronesia, Federated States of', code: 'FM'},
{name: 'Moldova, Republic of', code: 'MD'},
{name: 'Monaco', code: 'MC'},
{name: 'Mongolia', code: 'MN'},
{name: 'Montserrat', code: 'MS'},
{name: 'Morocco', code: 'MA'},
{name: 'Mozambique', code: 'MZ'},
{name: 'Myanmar', code: 'MM'},
{name: 'Namibia', code: 'NA'},
{name: 'Nauru', code: 'NR'},
{name: 'Nepal', code: 'NP'},
{name: 'Netherlands', code: 'NL'},
{name: 'Netherlands Antilles', code: 'AN'},
{name: 'New Caledonia', code: 'NC'},
{name: 'New Zealand', code: 'NZ'},
{name: 'Nicaragua', code: 'NI'},
{name: 'Niger', code: 'NE'},
{name: 'Nigeria', code: 'NG'},
{name: 'Niue', code: 'NU'},
{name: 'Norfolk Island', code: 'NF'},
{name: 'Northern Mariana Islands', code: 'MP'},
{name: 'Norway', code: 'NO'},
{name: 'Oman', code: 'OM'},
{name: 'Pakistan', code: 'PK'},
{name: 'Palau', code: 'PW'},
{name: 'Palestinian Territory, Occupied', code: 'PS'},
{name: 'Panama', code: 'PA'},
{name: 'Papua New Guinea', code: 'PG'},
{name: 'Paraguay', code: 'PY'},
{name: 'Peru', code: 'PE'},
{name: 'Philippines', code: 'PH'},
{name: 'Pitcairn', code: 'PN'},
{name: 'Poland', code: 'PL'},
{name: 'Portugal', code: 'PT'},
{name: 'Puerto Rico', code: 'PR'},
{name: 'Qatar', code: 'QA'},
{name: 'Reunion', code: 'RE'},
{name: 'Romania', code: 'RO'},
{name: 'Russian Federation', code: 'RU'},
{name: 'Rwanda', code: 'RW'},
{name: 'Saint Helena', code: 'SH'},
{name: 'Saint Kitts and Nevis', code: 'KN'},
{name: 'Saint Lucia', code: 'LC'},
{name: 'Saint Pierre and Miquelon', code: 'PM'},
{name: 'Saint Vincent and the Grenadines', code: 'VC'},
{name: 'Samoa', code: 'WS'},
{name: 'San Marino', code: 'SM'},
{name: 'Sao Tome and Principe', code: 'ST'},
{name: 'Saudi Arabia', code: 'SA'},
{name: 'Senegal', code: 'SN'},
{name: 'Serbia and Montenegro', code: 'CS'},
{name: 'Seychelles', code: 'SC'},
{name: 'Sierra Leone', code: 'SL'},
{name: 'Singapore', code: 'SG'},
{name: 'Slovakia', code: 'SK'},
{name: 'Slovenia', code: 'SI'},
{name: 'Solomon Islands', code: 'SB'},
{name: 'Somalia', code: 'SO'},
{name: 'South Africa', code: 'ZA'},
{name: 'South Georgia and the South Sandwich Islands', code: 'GS'},
{name: 'Spain', code: 'ES'},
{name: 'Sri Lanka', code: 'LK'},
{name: 'Sudan', code: 'SD'},
{name: 'Suriname', code: 'SR'},
{name: 'Svalbard and Jan Mayen', code: 'SJ'},
{name: 'Swaziland', code: 'SZ'},
{name: 'Sweden', code: 'SE'},
{name: 'Switzerland', code: 'CH'},
{name: 'Syrian Arab Republic', code: 'SY'},
{name: 'Taiwan, Province of China', code: 'TW'},
{name: 'Tajikistan', code: 'TJ'},
{name: 'Tanzania, United Republic of', code: 'TZ'},
{name: 'Thailand', code: 'TH'},
{name: 'Timor-Leste', code: 'TL'},
{name: 'Togo', code: 'TG'},
{name: 'Tokelau', code: 'TK'},
{name: 'Tonga', code: 'TO'},
{name: 'Trinidad and Tobago', code: 'TT'},
{name: 'Tunisia', code: 'TN'},
{name: 'Turkey', code: 'TR'},
{name: 'Turkmenistan', code: 'TM'},
{name: 'Turks and Caicos Islands', code: 'TC'},
{name: 'Tuvalu', code: 'TV'},
{name: 'Uganda', code: 'UG'},
{name: 'Ukraine', code: 'UA'},
{name: 'United Arab Emirates', code: 'AE'},
{name: 'United Kingdom', code: 'GB'},
{name: 'United States', code: 'US'},
{name: 'United States Minor Outlying Islands', code: 'UM'},
{name: 'Uruguay', code: 'UY'},
{name: 'Uzbekistan', code: 'UZ'},
{name: 'Vanuatu', code: 'VU'},
{name: 'Venezuela', code: 'VE'},
{name: 'Vietnam', code: 'VN'},
{name: 'Virgin Islands, British', code: 'VG'},
{name: 'Virgin Islands, U.S.', code: 'VI'},
{name: 'Wallis and Futuna', code: 'WF'},
{name: 'Western Sahara', code: 'EH'},
{name: 'Yemen', code: 'YE'},
{name: 'Zambia', code: 'ZM'},
{name: 'Zimbabwe', code: 'ZW'}
];
$scope.selectedIcon = '';
$scope.selectedIcons = ['Globe', 'Heart'];
$scope.icons = [
{value: 'Gear', label: '<i class="glyphicon glyphicon-cog"></i> Gear'},
{value: 'Globe', label: '<i class="glyphicon glyphicon-globe"></i> Globe'},
{value: 'Heart', label: '<i class="glyphicon glyphicon-heart"></i> Heart'},
{value: 'Camera', label: '<i class="glyphicon glyphicon-camera"></i> Camera'}
];
});
Scrollbar (baron.js)
Adds a simulated scrollbar to any element. It wraps the jQuery baron library.
Either add the bt-scrollbar
attribute, or use the <bt-scrollbar>
element.
Bacon ipsum dolor sit amet bresaola meatball ground round pariatur proident mollit prosciutto incididunt exercitation. Short ribs short loin qui jerky culpa. Ut ad hamburger shankle frankfurter aliqua. Kevin anim filet mignon bacon. Hamburger non quis, bacon flank rump commodo magna dolor enim pariatur dolore id nostrud. Short ribs minim adipisicing, boudin commodo dolore irure cillum turducken tail ground round. Do in occaecat quis salami veniam commodo cupidatat in flank spare ribs ham t-bone turducken shoulder.
Leberkas irure nisi veniam boudin id tempor eiusmod. Incididunt dolore commodo tongue reprehenderit, leberkas venison. Proident incididunt meatloaf sirloin. Consectetur ut frankfurter, pariatur drumstick enim proident. Swine occaecat beef, deserunt venison culpa corned beef short ribs meatball eu tail dolore filet mignon est kevin.
Non capicola velit pork loin. Cupidatat pastrami sausage pork loin ullamco jerky eiusmod. Est sunt ut frankfurter boudin dolore porchetta jowl. Ullamco sed kielbasa irure excepteur sausage. Pariatur bacon beef swine doner nostrud.
Minim meatloaf chuck sint, occaecat ea rump drumstick beef cillum salami nisi est. Salami shoulder occaecat turkey ribeye in pancetta est ut drumstick dolor biltong velit. Drumstick brisket adipisicing elit exercitation, in meatball ut ham doner irure pork id et. Turkey tongue elit in, aute kevin andouille biltong flank fugiat ullamco in. Doner hamburger bresaola tail porchetta pork consequat tongue magna pastrami.
Venison velit frankfurter, excepteur magna shank dolore. Cillum do short ribs aliqua doner drumstick. Eiusmod labore laboris sed kielbasa short ribs sint bacon corned beef adipisicing aute tri-tip. Ad biltong consequat ball tip sint consectetur, nulla chuck jowl fugiat pig est pork boudin.
<div bt-scrollbar>
scrollable content goes here
</div>
(function(mineralbayApp, baron) {
'use strict';
app.directive('btScrollbar', function($window) {
return {
restrict: 'EA',
transclude: true,
replace: true,
templateUrl: 'template/scrollbar/bt-scrollbar.tpl.html',
link: function(scope, element) {
var $element = angular.element(element);
var $scroller = $element.find('.baron-scroller')[0];
var $scrollbar = $element.find('.baron-scroller-bar')[0];
var scroll = baron({
root: element,
scroller: '.baron-scroller',
track: '.baron-scroller-track',
bar: '.baron-scroller-bar',
$: angular.element
});
// Seriously hacky. Need to add a subdirective for elements in the scrollbar that need to trigger the scroller update
// And need to bind a more generic event. Here we only update on click.
$element.on('click', function() {
$window.setTimeout(function() {
scroll.update();
checkHeight();
}, 400);
});
$element.on('mouseover', function() {
scroll.update();
checkHeight();
});
function checkHeight(){
if ($scroller.scrollHeight <= $scroller.clientHeight) {
$scrollbar.classList.add('hidden');
} else {
$scrollbar.classList.remove('hidden');
}
}
scope.$on('$destroy', function() {
scroll.dispose();
});
}
};
});
})(angular.module('mineralbayApp'), window.baron);
<div class="baron">
<div class="baron-scroller" ng-transclude></div>
<div class="baron-scroller-track">
<div class="baron-scroller-bar"></div>
</div>
</div>
Slider (angularjs-slider)
Simple slider
Range slider with min limit set to 10 and max limit set to 90
Range slider with a minimal range set to 10 and maximum of 50
Range slider with noSwitching=true
Range slider with minimum range of 10, maximum of 30 and pushRange option
Slider with visible selection bar
Slider with visible selection bar from a value
Slider with selection bar gradient
Slider with custom display function
Slider with custom display function using HTML formatting
Slider with ticks
Slider with ticks at intermediate positions
Slider with ticks at specific positions
Slider with ticks values, legend and tooltips
Slider with draggable range
Slider with draggable range only
Vertical sliders
Read-only slider
<h4>Simple slider</h4>
<rzslider rz-slider-model="slider.value"></rzslider>
<h4>Range slider with min limit set to 10 and max limit set to 90</h4>
<rzslider rz-slider-model="rangeSlider.minValue"
rz-slider-high="rangeSlider.maxValue"
rz-slider-options="rangeSlider.options"></rzslider>
<h4>Range slider with a minimal range set to 10 and maximum of 50</h4>
<rzslider rz-slider-model="rangeMinMaxSlider.minValue"
rz-slider-high="rangeMinMaxSlider.maxValue"
rz-slider-options="rangeMinMaxSlider.options"></rzslider>
<h4> Range slider with noSwitching=true</h4>
<rzslider rz-slider-model="rangeNoSwitchingSlider.minValue"
rz-slider-high="rangeNoSwitchingSlider.maxValue"
rz-slider-options="rangeNoSwitchingSlider.options"></rzslider>
<h4>Range slider with minimum range of 10, maximum of 30 and pushRange option</h4>
<rzslider rz-slider-model="rangePushRangeSlider.minValue"
rz-slider-high="rangePushRangeSlider.maxValue"
rz-slider-options="rangePushRangeSlider.options"></rzslider>
<h4>Slider with visible selection bar</h4>
<rzslider rz-slider-model="selectionBarSlider.value"
rz-slider-options="selectionBarSlider.options"></rzslider>
<h4>Slider with visible selection bar from a value</h4>
<rzslider rz-slider-model="selectionBarFromAValueSlider.value"
rz-slider-options="selectionBarFromAValueSlider.options"></rzslider>
<h4>Slider with selection bar gradient</h4>
<rzslider rz-slider-model="selectionBarWithGradientSlider.minValue"
rz-slider-high="selectionBarWithGradientSlidermaxValue"
rz-slider-options="selectionBarWithGradientSlider.options"></rzslider>
<h4>Slider with custom display function</h4>
<rzslider rz-slider-model="customDisplaySlider.minValue"
rz-slider-high="customDisplaySlider.maxValue"
rz-slider-options="customDisplaySlider.options"></rzslider>
<h4>Slider with custom display function using HTML formatting</h4>
<rzslider rz-slider-model="customDisplayUsingHTMLSlider.minValue"
rz-slider-high="customDisplayUsingHTMLSlider.maxValue"
rz-slider-options="customDisplayUsingHTMLSlider.options"></rzslider>
<h4>Slider with ticks</h4>
<rzslider rz-slider-model="ticksSlider.value"
rz-slider-options="ticksSlider.options"></rzslider>
<h4>Slider with ticks at intermediate positions</h4>
<rzslider rz-slider-model="ticksIntermediateSlider.value"
rz-slider-options="ticksIntermediateSlider.options"></rzslider>
<h4>Slider with ticks at specific positions</h4>
<rzslider rz-slider-model="ticksSpecificSlider.value"
rz-slider-options="ticksSpecificSlider.options"></rzslider>
<h4>Slider with ticks values, legend and tooltips</h4>
<rzslider rz-slider-model="ticksAndLegendsAndTooltipsSlider.value"
rz-slider-options="ticksAndLegendsAndTooltipsSlider.options"></rzslider>
<h4 style="padding-top:50px">Slider with draggable range</h4>
<rzslider rz-slider-model="draggableRangeSlider.minValue"
rz-slider-high="draggableRangeSlider.maxValue"
rz-slider-options="draggableRangeSlider.options"></rzslider>
<h4>Slider with draggable range only</h4>
<rzslider rz-slider-model="draggableRangeOnlySlider.minValue"
rz-slider-high="draggableRangeOnlySlider.maxValue"
rz-slider-options="draggableRangeOnlySlider.options"></rzslider>
<h4>Vertical sliders</h4>
<p style="height: 400px;width:600px;">
<rzslider style="padding-right:30px;" rz-slider-model="verticalSlider1.value"
rz-slider-options="verticalSlider1.options"></rzslider>
<rzslider style="padding-right:30px;" rz-slider-model="verticalSlider2.minValue" rz-slider-high="verticalSlider2.maxValue"
rz-slider-options="verticalSlider2.options"></rzslider>
<rzslider style="padding-right:30px;" rz-slider-model="verticalSlider3.value"
rz-slider-options="verticalSlider3.options"></rzslider>
<rzslider style="padding-right:30px;" rz-slider-model="verticalSlider4.minValue" rz-slider-high="verticalSlider4.maxValue"
rz-slider-options="verticalSlider4.options"></rzslider>
<rzslider style="padding-right:30px;" rz-slider-model="verticalSlider5.value"
rz-slider-options="verticalSlider5.options"></rzslider>
<rzslider style="padding-right:30px;" rz-slider-model="verticalSlider6.value"
rz-slider-options="verticalSlider6.options"></rzslider>
</p>
<h4>Read-only slider</h4>
<label>Read-only <input type="checkbox" ng-model="readOnlySlider.options.readOnly"></label>
<rzslider rz-slider-model="readOnlySlider.value"
rz-slider-options="readOnlySlider.options"></rzslider>
$scope.slider = {
value: 10
};
$scope.rangeSlider = {
minValue: 10,
maxValue: 90,
options: {
floor: 0,
ceil: 100,
step: 1,
minLimit: 10,
maxLimit: 90
}
};
$scope.rangeMinMaxSlider = {
minValue: 10,
maxValue: 90,
options: {
floor: 0,
ceil: 100,
step: 1,
minRange: 10,
maxRange: 50
}
};
$scope.rangeNoSwitchingSlider = {
minValue: 10,
maxValue: 90,
options: {
floor: 0,
ceil: 100,
step: 1,
noSwitching: true
}
};
$scope.rangePushRangeSlider = {
minValue: 60,
maxValue: 60,
options: {
floor: 0,
ceil: 100,
step: 1,
minRange: 10,
maxRange: 30,
pushRange: true
}
};
$scope.selectionBarSlider = {
value: 10,
options: {
showSelectionBar: true
}
};
$scope.selectionBarFromAValueSlider = {
value: 5,
options: {
floor: -10,
ceil: 10,
showSelectionBarFromValue: 0
}
};
$scope.selectionBarWithGradientSlider = {
minValue: 0,
maxValue: 80,
options: {
ceil: 100,
showSelectionBar: true,
selectionBarGradient: {
from: 'white',
to: '#FC0'
}
}
};
$scope.customDisplaySlider = {
minValue: 100,
maxValue: 400,
options: {
floor: 0,
ceil: 500,
translate: function(value) {
return '$' + value;
}
}
};
$scope.customDisplayUsingHTMLSlider = {
minValue: 100,
maxValue: 400,
options: {
floor: 0,
ceil: 500,
translate: function(value, sliderId, label) {
switch (label) {
case 'model':
return '<b>Min price:</b> $' + value;
case 'high':
return '<b>Max price:</b> $' + value;
default:
return '$' + value
}
}
}
};
$scope.ticksSlider = {
value: 5,
options: {
floor: 0,
ceil: 10,
showTicks: true
}
};
$scope.ticksIntermediateSlider = {
value: 55,
options: {
floor: 0,
ceil: 100,
showTicks: 10
}
};
$scope.ticksSpecificSlider = {
value: 55,
options: {
floor: 0,
ceil: 100,
ticksArray: [0, 10, 25, 50, 100]
}
};
$scope.ticksAndLegendsAndTooltipsSlider = {
value: 5,
options: {
showTicksValues: true,
ticksTooltip: function(v) {
return 'Tooltip for ' + v;
},
stepsArray: [
{value: 1, legend: 'Very poor'},
{value: 2},
{value: 3, legend: 'Fair'},
{value: 4},
{value: 5, legend: 'Average'},
{value: 6},
{value: 7, legend: 'Good'},
{value: 8},
{value: 9, legend: 'Excellent'}
]
}
};
$scope.draggableRangeSlider = {
minValue: 1,
maxValue: 8,
options: {
floor: 0,
ceil: 10,
draggableRange: true
}
};
$scope.draggableRangeOnlySlider = {
minValue: 4,
maxValue: 6,
options: {
floor: 0,
ceil: 10,
draggableRangeOnly: true
}
};
$scope.verticalSlider1 = {
value: 0,
options: {
floor: 0,
ceil: 10,
vertical: true
}
};
$scope.verticalSlider2 = {
minValue: 20,
maxValue: 80,
options: {
floor: 0,
ceil: 100,
vertical: true
}
};
$scope.verticalSlider3 = {
value: 5,
options: {
floor: 0,
ceil: 10,
vertical: true,
showTicks: true
}
};
$scope.verticalSlider4 = {
minValue: 1,
maxValue: 5,
options: {
floor: 0,
ceil: 6,
vertical: true,
showTicksValues: true
}
};
$scope.verticalSlider5 = {
value: 50,
options: {
floor: 0,
ceil: 100,
vertical: true,
showSelectionBar: true
}
};
$scope.verticalSlider6 = {
value: 6,
options: {
floor: 0,
ceil: 6,
vertical: true,
showSelectionBar: true,
showTicksValues: true,
ticksValuesTooltip: function (v) {
return 'Tooltip for ' + v;
}
}
};
$scope.readOnlySlider = {
value: 50,
options: {
floor: 0,
ceil: 100,
readOnly: true
}
};
.rzslider {
display: inline-block;
position: relative;
height: 4px;
width: 100%;
margin: 35px 0 15px 0;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.rzslider.with-legend {
margin-bottom: 40px;
}
.rzslider[disabled] {
cursor: not-allowed;
}
.rzslider[disabled] .rz-pointer {
cursor: not-allowed;
background-color: #d8e0f3;
}
.rzslider[disabled] .rz-draggable {
cursor: not-allowed;
}
.rzslider[disabled] .rz-selection {
background: #8b91a2;
}
.rzslider[disabled] .rz-tick {
cursor: not-allowed;
}
.rzslider[disabled] .rz-tick.rz-selected {
background: #8b91a2;
}
.rzslider span {
white-space: nowrap;
position: absolute;
display: inline-block;
}
.rzslider .rz-base {
width: 100%;
height: 100%;
padding: 0;
}
.rzslider .rz-bar-wrapper {
left: 0;
box-sizing: border-box;
margin-top: -16px;
padding-top: 16px;
width: 100%;
height: 32px;
z-index: 1;
}
.rzslider .rz-draggable {
cursor: move;
}
.rzslider .rz-bar {
left: 0;
width: 100%;
height: 4px;
z-index: 1;
background: #d8e0f3;
border-radius: 2px;
}
.rzslider .rz-bar-wrapper.rz-transparent .rz-bar {
background: transparent;
}
.rzslider .rz-bar-wrapper.rz-left-out-selection .rz-bar {
background: #df002d;
}
.rzslider .rz-bar-wrapper.rz-right-out-selection .rz-bar {
background: #03a688;
}
.rzslider .rz-selection {
z-index: 2;
background: #ee6023;
border-radius: 2px;
}
.rzslider .rz-pointer {
cursor: pointer;
width: 32px;
height: 32px;
top: -14px;
background-color: #ee6023;
z-index: 3;
border-radius: 16px;
}
.rzslider .rz-pointer:after {
content: '';
width: 8px;
height: 8px;
position: absolute;
top: 12px;
left: 12px;
border-radius: 4px;
background: #fff;
}
.rzslider .rz-pointer:hover:after {
background-color: #fff;
}
.rzslider .rz-pointer.rz-active {
z-index: 4;
}
.rzslider .rz-pointer.rz-active:after {
background-color: #b20001;
}
.rzslider .rz-bubble {
cursor: default;
bottom: 16px;
padding: 1px 3px;
color: #55637d;
}
.rzslider .rz-bubble.rz-limit {
color: #55637d;
}
.rzslider .rz-ticks {
box-sizing: border-box;
width: 100%;
height: 0;
position: absolute;
left: 0;
top: -3px;
margin: 0;
z-index: 1;
list-style: none;
}
.rzslider .rz-ticks-values-under .rz-tick-value {
top: auto;
bottom: -32px;
}
.rzslider .rz-tick {
text-align: center;
cursor: pointer;
width: 10px;
height: 10px;
background: #d8e0f3;
border-radius: 50%;
position: absolute;
top: 0;
left: 0;
margin-left: 11px;
}
.rzslider .rz-tick.rz-selected {
background: #ee6023;
}
.rzslider .rz-tick-value {
position: absolute;
top: -30px;
transform: translate(-50%, 0);
}
.rzslider .rz-tick-legend {
position: absolute;
top: 24px;
transform: translate(-50%, 0);
max-width: 50px;
white-space: normal;
}
.rzslider.rz-vertical {
position: relative;
width: 4px;
height: 100%;
margin: 0 20px;
padding: 0;
vertical-align: baseline;
}
.rzslider.rz-vertical .rz-base {
width: 100%;
height: 100%;
padding: 0;
}
.rzslider.rz-vertical .rz-bar-wrapper {
top: auto;
left: 0;
margin: 0 0 0 -16px;
padding: 0 0 0 16px;
height: 100%;
width: 32px;
}
.rzslider.rz-vertical .rz-bar {
bottom: 0;
left: auto;
width: 4px;
height: 100%;
}
.rzslider.rz-vertical .rz-pointer {
left: -14px !important;
top: auto;
bottom: 0;
}
.rzslider.rz-vertical .rz-bubble {
left: 16px !important;
margin-left: 3px;
bottom: 0;
}
.rzslider.rz-vertical .rz-ticks {
height: 100%;
width: 0;
left: -3px;
top: 0;
z-index: 1;
}
.rzslider.rz-vertical .rz-tick {
vertical-align: middle;
margin-left: auto;
margin-top: 11px;
}
.rzslider.rz-vertical .rz-tick-value {
left: 24px;
top: auto;
transform: translate(0, -28%);
}
.rzslider.rz-vertical .rz-tick-legend {
top: auto;
right: 24px;
transform: translate(0, -28%);
max-width: none;
white-space: nowrap;
}
.rzslider.rz-vertical .rz-ticks-values-under .rz-tick-value {
bottom: auto;
left: auto;
right: 24px;
}
Sorting Demo
# | Name | Birthday | Citizenship | Favorite Food and Drink |
---|---|---|---|---|
[[ person.nr ]] | [[ person.firstName ]] [[ person.lastName ]] | [[ person.citizenText ]] |
[[ person.food ]] [[ person.drink ]] |
<div class="table-responsive">
<table class="table table-condensed table-bordered table-striped">
<thead>
<tr>
<th>
<sort column-name="mineralbayApp.xy.name" data-uib-tooltip="Sort by name" sort-callback="loadAll()"
order-type="name" order-model="orderModel"></sort>
</th>
<tr>
</thead>
<tbody>
<tr ng-repeat="xy in xys">
<td>{{tunnelProject.projectName}}</td>
</tr>
</tbody>
</table>
</div>
----------------------------------------------------------------------------------------
sort.template.html:
<div class="breakNotAllowed" ng-click="sort()">
<span translate="{{columnName}}" class="breakAllowed">Name</span>
<span class="glyphicon"
ng-class="(orderType == orderModel.order_type && orderModel.order_direction=='DESC') ? 'glyphicon-arrow-up' : (orderType == orderModel.order_type && orderModel.order_direction == 'ASC' ?'glyphicon-arrow-down' : true)"></span>
</div>
.table {
font-size: 13px;
table-layout: fixed;
}
.table > thead > tr > th > sort {
text-align: center;
}
.table > thead > tr > th > sort:hover {
background: #C5E3EA;
color: #23527c;
cursor: pointer;
text-align: center;
}
.table > thead > tr > th,
.table > thead > tr > td {
background-color:rgba(141, 192, 219, 0.25);
}
.table > thead > tr > th:hover{
background-color: #C5E3EA;
color: #23527c;
}
Tabs (ui.bootstrap.tabs)
Select a tab by setting active binding to true:
Tabs using nested forms: Model:
[[ model | json ]]Nested Form:
[[ outerForm.nestedForm | json ]]
<p>Select a tab by setting active binding to true:</p>
<p>
<button type="button" class="btn btn-default btn-sm" ng-click="active = 1">Select second tab</button>
<button type="button" class="btn btn-default btn-sm" ng-click="active = 2">Select third tab</button>
</p>
<p>
<button type="button" class="btn btn-default btn-sm" ng-click="tabs[1].disabled = ! tabs[1].disabled">Enable / Disable third tab</button>
</p>
<hr />
<uib-tabset active="active">
<uib-tab index="0" heading="Static title">Static content</uib-tab>
<uib-tab index="$index + 1" ng-repeat="tab in tabs" heading="{{tab.title}}" disable="tab.disabled">
{{tab.content}}
</uib-tab>
<uib-tab index="3" select="alertMe()">
<uib-tab-heading>
<i class="glyphicon glyphicon-bell"></i> Alert!
</uib-tab-heading>
I've got an HTML heading, and a select callback. Pretty cool!
</uib-tab>
</uib-tabset>
<hr />
<uib-tabset active="activeJustified" justified="true">
<uib-tab index="0" heading="Justified">Justified content</uib-tab>
<uib-tab index="1" heading="SJ">Short Labeled Justified content</uib-tab>
<uib-tab index="2" heading="Long Justified">Long Labeled Justified content</uib-tab>
</uib-tabset>
<hr />
Tabs using nested forms:
<form name="outerForm" class="tab-form-demo">
<uib-tabset active="activeForm">
<uib-tab index="0" heading="Form Tab">
<ng-form name="nestedForm">
<div class="form-group">
<label>Name</label>
<input type="text" class="form-control" required ng-model="model.name"/>
</div>
</ng-form>
</uib-tab>
<uib-tab index="1" heading="Tab One">
Some Tab Content
</uib-tab>
<uib-tab index="2" heading="Tab Two">
More Tab Content
</uib-tab>
</uib-tabset>
</form>
Model:
<pre>{{ model | json }}</pre>
Nested Form:
<pre>{{ outerForm.nestedForm | json }}</pre>
app.controller(TabsDemoCtrl, function ($scope, $window) {
$scope.tabs = [
{ title:Dynamic Title 1, content:Dynamic content 1 },
{ title:Dynamic Title 2, content:Dynamic content 2, disabled: true }
];
$scope.alertMe = function() {
setTimeout(function() {
$window.alert(You\ve selected the alert tab!);
});
};
$scope.model = {
name: Tabs
};
});
.nav-tabs {
margin-bottom: 10px;
}
.nav-tabs > li > a {
border-radius: 0;
color: #337ab7;
cursor: pointer;
margin-right: -1px;
}
.nav-tabs > li > a:hover,
.nav-tabs > li > a:focus {
box-shadow: none;
background-color: #fefefe;
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
border-top-color: #ee6023;
}
.nav-tabs > li.active > a:after,
.nav-tabs > li.active > a:hover:after,
.nav-tabs > li.active > a:focus:after {
content: "";
height: 2px;
left: -1px;
position: absolute;
right: -1px;
top: 0;
background-color: #ee6023;
}
.nav-tabs > li.open > a,
.nav-tabs > li.open > a:hover,
.nav-tabs > li.open > a:focus {
background-color: #fefefe;
border-color: #cccccc;
}
.nav-tabs.nav-justified > li > a {
border-bottom: 1px solid #cccccc;
margin-right: 0;
margin-bottom: 0;
margin-left: -1px;
border-radius: 0;
}
.nav-tabs.nav-justified > li:first-child > a {
margin-left: 0;
}
.nav-tabs.nav-justified > .active > a,
.nav-tabs.nav-justified > .active > a:hover,
.nav-tabs.nav-justified > .active > a:focus {
border-top-color: #ee6023;
border-bottom-color: #ffffff;
}
.nav-tabs > li.active > a:focus {
color: #ee6023;
}
uib-tabset settings
active
(Default:Index of first tab
) - Active index of tab. Setting this to an existing tab index will make that tab active.justified
$ (Default:false
) - Whether tabs fill the container and have a consistent width.template-url
(Default:uib/template/tabs/tabset.html
) - A URL representing the location of a template to use for the main component.
type
(Defaults:tabs
) - Navigation type. Possible values are 'tabs' and 'pills'.vertical
$ (Default:false
) - Whether tabs appear vertically stacked.
uib-tab settings
classes
$ - An optional string of space-separated CSS classes.deselect()
$ - An optional expression called when tab is deactivated. Supports$event
and$selectedIndex
in template for expression. You may call$event.preventDefault()
in this event handler to prevent a tab change from occurring. The$selectedIndex
can be used to determine which tab was attempted to be opened.disable
$ (Default:false
) - Whether tab is clickable and can be activated.heading
- Heading text.index
- Tab index. Must be unique number or string.select()
$ - An optional expression called when tab is activated. Supports $event in template for expression.template-url
(Default:uib/template/tabs/tab.html
) - A URL representing the location of a template to use for the tab heading.
Tabset heading
Instead of the heading
attribute on the uib-tabset
, you can use an uib-tab-heading
element inside a tabset that will be used as the tabset's header. There you can use HTML as well.
Known issues
To use clickable elements within the tab, you have override the tab template to use div elements instead of anchor elements, and replicate the desired styles from Bootstrap's CSS. This is due to browsers interpreting anchor elements as the target of any click event, which triggers routing when certain elements such as buttons are nested inside the anchor element.
Timepicker (ui.bootstrap.timepicker)
Time is: [[ mytime | date:'shortTime' ]]
<div uib-timepicker ng-model="mytime" ng-change="changed()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"></div>
<pre class="alert alert-info">Time is: {{mytime | date:'shortTime' }}</pre>
<div class="row">
<div class="col-xs-6">
Hours step is:
<select class="form-control" ng-model="hstep" ng-options="opt for opt in options.hstep"></select>
</div>
<div class="col-xs-6">
Minutes step is:
<select class="form-control" ng-model="mstep" ng-options="opt for opt in options.mstep"></select>
</div>
</div>
<button type="button" class="btn btn-info" ng-click="toggleMode()">12H / 24H</button>
<button type="button" class="btn btn-default" ng-click="update()">Set to 14:00</button>
<button type="button" class="btn btn-danger" ng-click="clear()">Clear</button>
app.controller('TimepickerDemoCtrl', function ($scope, $log) {
$scope.mytime = new Date();
$scope.hstep = 1;
$scope.mstep = 15;
$scope.options = {
hstep: [1, 2, 3],
mstep: [1, 5, 10, 15, 25, 30]
};
$scope.ismeridian = true;
$scope.toggleMode = function() {
$scope.ismeridian = ! $scope.ismeridian;
};
$scope.update = function() {
var d = new Date();
d.setHours( 14 );
d.setMinutes( 0 );
$scope.mytime = d;
};
$scope.changed = function () {
$log.log('Time changed to: ' + $scope.mytime);
};
$scope.clear = function() {
$scope.mytime = null;
};
});
uib-timepicker settings
arrowkeys
$ C (Default:true
) - Whether user can use up/down arrow keys inside the hours & minutes input to increase or decrease its values.hour-step
$ C (Default:1
) - Number of hours to increase or decrease when using a button.max
$ (Default:undefined
) - Maximum time a user can select.meridians
$ C (Default:null
) - Meridian labels based on locale. To override you must supply an array like['AM', 'PM']
.min
$ (Default:undefined
) - Minimum time a user can selectminute-step
$ C (Default:1
) - Number of minutes to increase or decrease when using a button.mousewheel
$ C (Default:true
) - Whether user can scroll inside the hours & minutes input to increase or decrease its values.ng-disabled
$ (Default:false
) - Whether or not to disable the component.ng-model
$ - Date object that provides the time state.pad-hours
$ (Default: true) - Whether the hours column is padded with a 0.readonly-input
$ C (Default:false
) - Whether user can type inside the hours & minutes input.second-step
$ C (Default:1
) - Number of seconds to increase or decrease when using a button.show-meridian
$ C (Default:true
) - Whether to display 12H or 24H mode.show-seconds
$ C (Default:false
) - Show seconds input.show-spinners
$ C (Default:true
) - Show spinner arrows above and below the inputs.tabindex
(Defaults:0
) - Sets tabindex for each control in the timepicker.template-url
C (Defaults:uib/template/timepicker/timepicker.html
) - Add the ability to override the template used on the component.
Notes
This component makes no claims of absolutely supporting the preservation of dates in all cases, and it is highly recommended that model tracking of dates is encapsulated in a different object. This component should not be used with the same model as the datepicker. This is due to edge cases with situations such as Daylight Savings timezone changes which require a modification of the date in order to prevent an impossible to increment or decrement situation. See #5485 for details.
If the model value is updated (i.e. via Date.prototype.setDate
), you must update the model value by breaking the reference by modelValue = new Date(modelValue)
in order to have the timepicker update.
Tooltip (ui.bootstrap.tooltip)
A lightweight, extensible directive for fancy tooltip creation. The tooltip directive supports multiple placements, optional transition animation, and more.
Note to mobile developers: Please note that while tooltips may work correctly on mobile devices (including tablets), we have made the decision to not officially support such a use-case because it does not make sense from a UX perspective.
There are three versions of the tooltip: uib-tooltip
, uib-tooltip-template
, and
uib-tooltip-html
:
uib-tooltip
- Takes text only and will escape any HTML provided.uib-tooltip-html
$ - Takes an expression that evaluates to an HTML string. Note that this HTML is not compiled. If compilation is required, please use theuib-tooltip-template
attribute option instead. The user is responsible for ensuring the content is safe to put into the DOM!uib-tooltip-template
$ - Takes text that specifies the location of a template to use for the tooltip. Note that this needs to be wrapped in a tag.
Pellentesque [[dynamicTooltipText]], sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam. Tincidunt lobortis feugiat vivamus at fading eget arcu dictum varius duis at consectetur lorem. Vitae elementum curabitur show delay nunc sed velit dignissim sodales ut eu sem integer vitae. Turpis egestas hide delay pharetra convallis posuere morbi leo urna, Custom template at elementum eu, facilisis sed odio morbi quis commodo odio.
I can even contain HTML as a scope variable or inline string
I can have a custom class. Check me out!
<div ng-controller="TooltipDemoCtrl">
<div class="form-group">
<label>Tooltip placement</label>
<select class="form-control" ng-model="placement.selected" ng-options="o as o for o in placement.options"></select>
</div>
<button tooltip-placement="{{placement.selected}}" uib-tooltip="On the {{placement.selected}}" type="button" class="btn btn-default">Tooltip {{placement.selected}}</button>
<hr />
<div class="form-group">
<label>Dynamic Tooltip Text</label>
<input type="text" ng-model="dynamicTooltipText" class="form-control">
</div>
<div class="form-group">
<label>Dynamic Tooltip Popup Text</label>
<input type="text" ng-model="dynamicTooltip" class="form-control">
</div>
<p>
Pellentesque <a href="#" uib-tooltip="{{dynamicTooltip}}">{{dynamicTooltipText}}</a>,
sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in
aliquam. Tincidunt lobortis feugiat vivamus at
<a href="#" tooltip-animation="false" uib-tooltip="I don't fade. :-(">fading</a>
eget arcu dictum varius duis at consectetur lorem. Vitae elementum curabitur
<a href="#" tooltip-popup-delay='1000' uib-tooltip='appears with delay'>show delay</a>
nunc sed velit dignissim sodales ut eu sem integer vitae. Turpis egestas
<a href="#" tooltip-popup-close-delay='1000' uib-tooltip='hides with delay'>hide delay</a>
pharetra convallis posuere morbi leo urna,
<a href="#" uib-tooltip-template="'myTooltipTemplate.html'">Custom template</a>
at elementum eu, facilisis sed odio morbi quis commodo odio.
</p>
<p>
I can even contain HTML as a
<a href="#" uib-tooltip-html="htmlTooltip">scope variable</a> or
<a href="#" uib-tooltip-html="'static. {{dynamicTooltipText}}. <b>bold.</b>'">inline string</a>
</p>
<p>
<style>
/* Specify styling for tooltip contents */
.tooltip.customClass .tooltip-inner {
color: #880000;
background-color: #ffff66;
box-shadow: 0 6px 12px rgba(0,0,0,.175);
}
/* Hide arrow */
.tooltip.customClass .tooltip-arrow {
display: none;
}
</style>
I can have a custom class. <a href="#" uib-tooltip="I can have a custom class applied to me!" tooltip-class="customClass">Check me out!</a>
</p>
<div class="form-group">
<label>Or use custom triggers, like focus: </label>
<input type="text" value="Click me!" uib-tooltip="See? Now click away..." tooltip-trigger="'focus'" tooltip-placement="right" class="form-control" />
</div>
<div class="form-group" ng-class="{'has-error' : !inputModel}">
<label>Disable tooltips conditionally:</label>
<input type="text" ng-model="inputModel" class="form-control"
placeholder="Hover over this for a tooltip until this is filled"
uib-tooltip="Enter something in this input field to disable this tooltip"
tooltip-placement="top"
tooltip-trigger="'mouseenter'"
tooltip-enable="!inputModel" />
</div>
<div class="form-group">
<label>
Open tooltips <span uib-tooltip="Hello!" tooltip-is-open="tooltipIsOpen" tooltip-placement="bottom">conditionally.</span>
</label>
<button ng-click="tooltipIsOpen = !tooltipIsOpen">Toggle tooltip</button>
</div>
<script type="text/ng-template" id="myTooltipTemplate.html">
<span>Special Tooltip with <strong>markup</strong> and {{ dynamicTooltipText }}</span>
</script>
</div>
app.controller('TooltipDemoCtrl', function ($scope, $sce) {
$scope.dynamicTooltip = 'Hello, World!';
$scope.dynamicTooltipText = 'dynamic';
$scope.htmlTooltip = $sce.trustAsHtml('I\'ve been made <b>bold</b>!');
$scope.placement = {
options: [
'top',
'top-left',
'top-right',
'bottom',
'bottom-left',
'bottom-right',
'left',
'left-top',
'left-bottom',
'right',
'right-top',
'right-bottom'
],
selected: 'top'
};
});
uib-tooltip-settings
All these settings are available for the three types of tooltips.
tooltip-animation
$ C (Default:true
, Config:animation
) - Should it fade in and out?tooltip-append-to-body
$ C (Default:false
, Config:appendToBody
) - Should the tooltip be appended to '$body' instead of the parent element?tooltip-class
- Custom class to be applied to the tooltip.tooltip-enable
$ (Default:true
) - Is it enabled? It will enable or disable the configured tooltip-trigger.tooltip-is-open
(Default:false
) - Whether to show the tooltip.tooltip-placement
C (Default:top
, Config:placement
) - Passing in 'auto' separated by a space before the placement will enable auto positioning, e.g: "auto bottom-left". The tooltip will attempt to position where it fits in the closest scrollable ancestor. Accepts:top
- tooltip on top, horizontally centered on host element.top-left
- tooltip on top, left edge aligned with host element left edge.top-right
- tooltip on top, right edge aligned with host element right edge.bottom
- tooltip on bottom, horizontally centered on host element.bottom-left
- tooltip on bottom, left edge aligned with host element left edge.bottom-right
- tooltip on bottom, right edge aligned with host element right edge.left
- tooltip on left, vertically centered on host element.left-top
- tooltip on left, top edge aligned with host element top edge.left-bottom
- tooltip on left, bottom edge aligned with host element bottom edge.right
- tooltip on right, vertically centered on host element.right-top
- tooltip on right, top edge aligned with host element top edge.right-bottom
- tooltip on right, bottom edge aligned with host element bottom edge.
tooltip-popup-close-delay
C (Default:0
, Config:popupCloseDelay
) - For how long should the tooltip remain open after the close trigger event?tooltip-popup-delay
C (Default:0
, Config:popupDelay
) - Popup delay in milliseconds until it opens.tooltip-trigger
$ (Default:'mouseenter'
) - What should trigger a show of the tooltip? Supports a space separated list of event names, or objects (see below).
Note: To configure the tooltips, you need to do it on $uibTooltipProvider
(also see below).
Triggers
The following show triggers are supported out of the box, along with their provided hide triggers:
mouseenter
:mouseleave
click
:click
outsideClick
:outsideClick
focus
:blur
none
The outsideClick
trigger will cause the tooltip to toggle on click, and hide when anything else is clicked.
For any non-supported value, the trigger will be used to both show and hide the
tooltip. Using the 'none' trigger will disable the internal trigger(s), one can
then use the tooltip-is-open
attribute exclusively to show and hide the tooltip.
$uibTooltipProvider
Through the $uibTooltipProvider
, you can change the way tooltips and popovers
behave by default; the attributes above always take precedence. The following
methods are available:
setTriggers(obj)
(Example:{ 'openTrigger': 'closeTrigger' }
) - Extends the default trigger mappings mentioned above with mappings of your own.options(obj)
- Provide a set of defaults for certain tooltip and popover attributes. Currently supports the ones with the C badge.
Known issues
For Safari 7+ support, if you want to use the focus tooltip-trigger
, you need to use an anchor tag with a tab index. For example:
<a tabindex="0" uib-tooltip="Test" tooltip-trigger="focus" class="btn btn-default">
Click Me
</a>
For Safari (potentially all versions up to 9), there is an issue with the hover CSS selector when using multiple elements grouped close to each other that are using the tooltip - it is possible for multiple elements to gain the hover state when mousing between the elements quickly and exiting the container at the right time. See issue #5445 for more details.
Typeahead (ui.bootstrap.typeahead)
Typeahead is a AngularJS version of Bootstrap v2's typeahead plugin. This directive can be used to quickly create elegant typeaheads with any form text input.
It is very well integrated into AngularJS as it uses a subset of the select directive syntax, which is very flexible. Supported expressions are:
- label for value in sourceArray
- select as label for value in sourceArray
The sourceArray
expression can use a special $viewValue
variable that corresponds to the value entered inside the input.
This directive works with promises, meaning you can retrieve matches using the $http
service with minimal effort.
Static arrays
Model: [[selected | json]]
Asynchronous results
Model: [[asyncSelected | json]]
ngModelOptions support
Model: [[ngModelOptionsSelected | json]]
Custom templates for results
Model: [[customSelected | json]]
Custom popup templates for typeahead's dropdown
Model: [[customPopupSelected | json]]
<script type="text/ng-template" id="customTemplate.html">
<a>
<img ng-src="http://upload.wikimedia.org/wikipedia/commons/thumb/{{match.model.flag}}" width="16">
<span ng-bind-html="match.label | uibTypeaheadHighlight:query"></span>
</a>
</script>
<script type="text/ng-template" id="customPopupTemplate.html">
<div class="custom-popup-wrapper"
ng-style="{top: position().top+'px', left: position().left+'px'}"
style="display: block;"
ng-show="isOpen() && !moveInProgress"
aria-hidden="{{!isOpen()}}">
<p class="message">select location from drop down.</p>
<ul class="dropdown-menu" role="listbox">
<li class="uib-typeahead-match" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }"
ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{::match.id}}">
<div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
</li>
</ul>
</div>
</script>
<div class='container-fluid typeahead-demo' ng-controller="TypeaheadCtrl">
<h4>Static arrays</h4>
<pre>Model: {{selected | json}}</pre>
<input type="text" ng-model="selected" uib-typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control">
<h4>Asynchronous results</h4>
<pre>Model: {{asyncSelected | json}}</pre>
<input type="text" ng-model="asyncSelected" placeholder="Locations loaded via $http" uib-typeahead="address for address in getLocation($viewValue)" typeahead-loading="loadingLocations" typeahead-no-results="noResults" class="form-control">
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found
</div>
<h4>ngModelOptions support</h4>
<pre>Model: {{ngModelOptionsSelected | json}}</pre>
<input type="text" ng-model="ngModelOptionsSelected" ng-model-options="modelOptions" uib-typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control">
<h4>Custom templates for results</h4>
<pre>Model: {{customSelected | json}}</pre>
<input type="text" ng-model="customSelected" placeholder="Custom template" uib-typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-template-url="customTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0">
<h4>Custom popup templates for typeahead's dropdown</h4>
<pre>Model: {{customPopupSelected | json}}</pre>
<input type="text" ng-model="customPopupSelected" placeholder="Custom popup template" uib-typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-popup-template-url="customPopupTemplate.html" class="form-control">
</div>
app.controller('TypeaheadCtrl', function($scope, $http) {
var _selected;
$scope.selected = undefined;
$scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
// Any function returning a promise object can be used to load values asynchronously
$scope.getLocation = function(val) {
return $http.get('//maps.googleapis.com/maps/api/geocode/json', {
params: {
address: val,
sensor: false
}
}).then(function(response){
return response.data.results.map(function(item){
return item.formatted_address;
});
});
};
$scope.ngModelOptionsSelected = function(value) {
if (arguments.length) {
_selected = value;
} else {
return _selected;
}
};
$scope.modelOptions = {
debounce: {
default: 500,
blur: 250
},
getterSetter: true
};
$scope.statesWithFlags = [{'name':'Alabama','flag':'5/5c/Flag_of_Alabama.svg/45px-Flag_of_Alabama.svg.png'},{'name':'Alaska','flag':'e/e6/Flag_of_Alaska.svg/43px-Flag_of_Alaska.svg.png'},{'name':'Arizona','flag':'9/9d/Flag_of_Arizona.svg/45px-Flag_of_Arizona.svg.png'},{'name':'Arkansas','flag':'9/9d/Flag_of_Arkansas.svg/45px-Flag_of_Arkansas.svg.png'},{'name':'California','flag':'0/01/Flag_of_California.svg/45px-Flag_of_California.svg.png'},{'name':'Colorado','flag':'4/46/Flag_of_Colorado.svg/45px-Flag_of_Colorado.svg.png'},{'name':'Connecticut','flag':'9/96/Flag_of_Connecticut.svg/39px-Flag_of_Connecticut.svg.png'},{'name':'Delaware','flag':'c/c6/Flag_of_Delaware.svg/45px-Flag_of_Delaware.svg.png'},{'name':'Florida','flag':'f/f7/Flag_of_Florida.svg/45px-Flag_of_Florida.svg.png'},{'name':'Georgia','flag':'5/54/Flag_of_Georgia_%28U.S._state%29.svg/46px-Flag_of_Georgia_%28U.S._state%29.svg.png'},{'name':'Hawaii','flag':'e/ef/Flag_of_Hawaii.svg/46px-Flag_of_Hawaii.svg.png'},{'name':'Idaho','flag':'a/a4/Flag_of_Idaho.svg/38px-Flag_of_Idaho.svg.png'},{'name':'Illinois','flag':'0/01/Flag_of_Illinois.svg/46px-Flag_of_Illinois.svg.png'},{'name':'Indiana','flag':'a/ac/Flag_of_Indiana.svg/45px-Flag_of_Indiana.svg.png'},{'name':'Iowa','flag':'a/aa/Flag_of_Iowa.svg/44px-Flag_of_Iowa.svg.png'},{'name':'Kansas','flag':'d/da/Flag_of_Kansas.svg/46px-Flag_of_Kansas.svg.png'},{'name':'Kentucky','flag':'8/8d/Flag_of_Kentucky.svg/46px-Flag_of_Kentucky.svg.png'},{'name':'Louisiana','flag':'e/e0/Flag_of_Louisiana.svg/46px-Flag_of_Louisiana.svg.png'},{'name':'Maine','flag':'3/35/Flag_of_Maine.svg/45px-Flag_of_Maine.svg.png'},{'name':'Maryland','flag':'a/a0/Flag_of_Maryland.svg/45px-Flag_of_Maryland.svg.png'},{'name':'Massachusetts','flag':'f/f2/Flag_of_Massachusetts.svg/46px-Flag_of_Massachusetts.svg.png'},{'name':'Michigan','flag':'b/b5/Flag_of_Michigan.svg/45px-Flag_of_Michigan.svg.png'},{'name':'Minnesota','flag':'b/b9/Flag_of_Minnesota.svg/46px-Flag_of_Minnesota.svg.png'},{'name':'Mississippi','flag':'4/42/Flag_of_Mississippi.svg/45px-Flag_of_Mississippi.svg.png'},{'name':'Missouri','flag':'5/5a/Flag_of_Missouri.svg/46px-Flag_of_Missouri.svg.png'},{'name':'Montana','flag':'c/cb/Flag_of_Montana.svg/45px-Flag_of_Montana.svg.png'},{'name':'Nebraska','flag':'4/4d/Flag_of_Nebraska.svg/46px-Flag_of_Nebraska.svg.png'},{'name':'Nevada','flag':'f/f1/Flag_of_Nevada.svg/45px-Flag_of_Nevada.svg.png'},{'name':'New Hampshire','flag':'2/28/Flag_of_New_Hampshire.svg/45px-Flag_of_New_Hampshire.svg.png'},{'name':'New Jersey','flag':'9/92/Flag_of_New_Jersey.svg/45px-Flag_of_New_Jersey.svg.png'},{'name':'New Mexico','flag':'c/c3/Flag_of_New_Mexico.svg/45px-Flag_of_New_Mexico.svg.png'},{'name':'New York','flag':'1/1a/Flag_of_New_York.svg/46px-Flag_of_New_York.svg.png'},{'name':'North Carolina','flag':'b/bb/Flag_of_North_Carolina.svg/45px-Flag_of_North_Carolina.svg.png'},{'name':'North Dakota','flag':'e/ee/Flag_of_North_Dakota.svg/38px-Flag_of_North_Dakota.svg.png'},{'name':'Ohio','flag':'4/4c/Flag_of_Ohio.svg/46px-Flag_of_Ohio.svg.png'},{'name':'Oklahoma','flag':'6/6e/Flag_of_Oklahoma.svg/45px-Flag_of_Oklahoma.svg.png'},{'name':'Oregon','flag':'b/b9/Flag_of_Oregon.svg/46px-Flag_of_Oregon.svg.png'},{'name':'Pennsylvania','flag':'f/f7/Flag_of_Pennsylvania.svg/45px-Flag_of_Pennsylvania.svg.png'},{'name':'Rhode Island','flag':'f/f3/Flag_of_Rhode_Island.svg/32px-Flag_of_Rhode_Island.svg.png'},{'name':'South Carolina','flag':'6/69/Flag_of_South_Carolina.svg/45px-Flag_of_South_Carolina.svg.png'},{'name':'South Dakota','flag':'1/1a/Flag_of_South_Dakota.svg/46px-Flag_of_South_Dakota.svg.png'},{'name':'Tennessee','flag':'9/9e/Flag_of_Tennessee.svg/46px-Flag_of_Tennessee.svg.png'},{'name':'Texas','flag':'f/f7/Flag_of_Texas.svg/45px-Flag_of_Texas.svg.png'},{'name':'Utah','flag':'f/f6/Flag_of_Utah.svg/45px-Flag_of_Utah.svg.png'},{'name':'Vermont','flag':'4/49/Flag_of_Vermont.svg/46px-Flag_of_Vermont.svg.png'},{'name':'Virginia','flag':'4/47/Flag_of_Virginia.svg/44px-Flag_of_Virginia.svg.png'},{'name':'Washington','flag':'5/54/Flag_of_Washington.svg/46px-Flag_of_Washington.svg.png'},{'name':'West Virginia','flag':'2/22/Flag_of_West_Virginia.svg/46px-Flag_of_West_Virginia.svg.png'},{'name':'Wisconsin','flag':'2/22/Flag_of_Wisconsin.svg/45px-Flag_of_Wisconsin.svg.png'},{'name':'Wyoming','flag':'b/bc/Flag_of_Wyoming.svg/43px-Flag_of_Wyoming.svg.png'}];
});
<style>
.typeahead-demo .custom-popup-wrapper {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
background-color: #f9f9f9;
}
.typeahead-demo .custom-popup-wrapper > .message {
padding: 10px 20px;
border-bottom: 1px solid #ddd;
color: #868686;
}
.typeahead-demo .custom-popup-wrapper > .dropdown-menu {
position: static;
float: none;
display: block;
min-width: 160px;
background-color: transparent;
border: none;
border-radius: 0;
box-shadow: none;
}
</style>
uib-typeahead settings
ng-model
$ - Assignable angular expression to data-bind to.ng-model-options
$ - Options for ng-model (see ng-model-options directive). Currently supports thedebounce
andgetterSetter
options.typeahead-append-to
$ (Default:null
) - Should the typeahead popup be appended to an element instead of the parent element?typeahead-append-to-body
$ (Default:false
) - Should the typeahead popup be appended to $body instead of the parent element?typeahead-editable
$ (Default:true
) - Should it restrict model values to the ones selected from the popup only?typeahead-focus-first
$ (Default:true
) - Should the first match automatically be focused as you type?typeahead-focus-on-select
(Default:true
) - On selection, focus the input element the typeahead directive is associated with.typeahead-input-formatter
(Default:undefined
) - Format the ng-model result after selection.typeahead-is-open
$ (Default:angular.noop
) - Binding to a variable that indicates if the dropdown is open.typeahead-loading
$ (Default:angular.noop
) - Binding to a variable that indicates if matches are being retrieved asynchronously.typeahead-min-length
$ (Default:1
) - Minimal no of characters that needs to be entered before typeahead kicks-in. Must be greater than or equal to 0.typeahead-no-results
$ (Default:angular.noop
) - Binding to a variable that indicates if no matching results were found.typeahead-should-select($event)
$ (Default:null
) - A callback executed when akeyup
event that might trigger a selection occurs. Selection will only occur if this function returns true.typeahead-on-select($item, $model, $label, $event)
$ (Default:null
) - A callback executed when a match is selected. $event can be undefined if selection not triggered from a user event.typeahead-popup-template-url
(Default:uib/template/typeahead/typeahead-popup.html
) - Set custom popup template.typeahead-select-on-blur
$ (Default:false
) - On blur, select the currently highlighted match.typeahead-select-on-exact
$ (Default:false
) - Automatically select the item when it is the only one that exactly matches the user input.typeahead-show-hint
$ (Default:false
) - Show hint when the first option matches.typeahead-template-url
(Default:uib/template/typeahead/typeahead-match.html
) - Set custom item template.typeahead-wait-ms
$ (Default:0
) - Minimal wait time after last character typed before typeahead kicks-in.uib-typeahead
$ - Comprehension Angular expression (see select directive).
Notes
If a custom template for the popup is used, the wrapper selector used for the match items is the uib-typeahead-match
class.
Wizard (angular-wizard)
This is the first step
Here you can use whatever you want. You can use other directives, binding, etc.
Continuing
You have continued here!
Even more steps!!
<wizard on-finish="finishedWizard()" on-cancel="cancelledWizard()">
<wz-step wz-title="Starting">
<h1>This is the first step</h1>
<p>Here you can use whatever you want. You can use other directives, binding, etc.</p>
<input type="submit" wz-next value="Continue" />
</wz-step>
<wz-step wz-title="Continuing">
<h1>Continuing</h1>
<p>You have continued here!</p>
<input type="submit" wz-next value="Go on" />
</wz-step>
<wz-step wz-title="More steps">
<p>Even more steps!!</p>
<input type="submit" wz-next value="Finish now" />
</wz-step>
</wizard>
.steps-indicator {
/* ---- steps quantity ---- */
right: 0;
bottom: 0;
left: 0;
margin: 0;
padding: 20px 0 0 0;
height: 30px;
list-style: none;
}
.steps-indicator:before {
background-color: #E6E6E6;
content: '';
position: absolute;
height: 1px;
}
.steps-indicator.steps-2:before {
left: calc(100% / 2 / 2);
right: calc(100% / 2 / 2);
}
.steps-indicator.steps-3:before {
left: calc(100% / 3 / 2);
right: calc(100% / 3 / 2);
}
.steps-indicator.steps-4:before {
left: calc(100% / 4 / 2);
right: calc(100% / 4 / 2);
}
.steps-indicator.steps-5:before {
left: calc(100% / 5 / 2);
right: calc(100% / 5 / 2);
}
.steps-indicator.steps-6:before {
left: calc(100% / 6 / 2);
right: calc(100% / 6 / 2);
}
.steps-indicator.steps-7:before {
left: calc(100% / 7 / 2);
right: calc(100% / 7 / 2);
}
.steps-indicator.steps-8:before {
left: calc(100% / 8 / 2);
right: calc(100% / 8 / 2);
}
.steps-indicator.steps-9:before {
left: calc(100% / 9 / 2);
right: calc(100% / 9 / 2);
}
.steps-indicator.steps-10:before {
left: calc(100% / 10 / 2);
right: calc(100% / 10 / 2);
}
.steps-indicator * {
box-sizing: border-box;
}
.steps-indicator li {
position: relative;
float: left;
margin: 0;
padding: 0;
padding-top: 10px;
text-align: center;
line-height: 15px;
}
.steps-indicator li a {
color: #808080;
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
transition: 0.25s;
cursor: pointer;
}
.steps-indicator li a:before {
position: absolute;
top: -7px;
left: calc(50% - 7px);
width: 14px;
height: 14px;
border-radius: 100%;
background-color: #E6E6E6;
content: '';
transition: 0.25s;
}
.steps-indicator li a:hover {
color: #4d4d4d;
}
.steps-indicator.steps-2 li {
width: calc(100% / 2);
}
.steps-indicator.steps-3 li {
width: calc(100% / 3);
}
.steps-indicator.steps-4 li {
width: calc(100% / 4);
}
.steps-indicator.steps-5 li {
width: calc(100% / 5);
}
.steps-indicator.steps-6 li {
width: calc(100% / 6);
}
.steps-indicator.steps-7 li {
width: calc(100% / 7);
}
.steps-indicator.steps-8 li {
width: calc(100% / 8);
}
.steps-indicator.steps-9 li {
width: calc(100% / 9);
}
.steps-indicator.steps-10 li {
width: calc(100% / 10);
}
.steps-indicator.steps-11 li {
width: calc(100% / 11);
}
.steps-indicator li.default {
pointer-events: none;
}
.steps-indicator li.default a:hover {
color: #808080;
}
.steps-indicator li.current,
.steps-indicator li.editing {
pointer-events: none;
}
.steps-indicator li.current a:before {
background-color: #ee6023;
}
.steps-indicator li.done a:before {
background-color: #339933;
}
.steps-indicator li.editing a:before {
background-color: #ee6023;
}
Angular-xeditable (angular-xeditable)
<form editable-form name="editableForm" onaftersave="saveUser()">
<div>
<!-- editable username (text with validation) -->
<span class="title">User name: </span>
<span editable-text="user.name" e-name="name" onbeforesave="checkName($data)" e-required></span>
</div>
<div>
<!-- editable status (select-local) -->
<span class="title">Status: </span>
<span editable-select="user.status" e-name="status" e-ng-options="s.value as s.text for s in statuses">
{{ (statuses | filter:{value: user.status})[0].text || 'Not set' }}
</span>
</div>
<div>
<!-- editable group (select-remote) -->
<span class="title">Group: </span>
<span editable-select="user.group" e-name="group" onshow="loadGroups()" e-ng-options="g.id as g.text for g in groups">
{{ showGroup() }}
</span>
</div>
<div>
<!-- button to show form -->
<button type="button" class="btn btn-default" ng-click="editableForm.$show()" ng-show="!editableForm.$visible">
Edit
</button>
<!-- buttons to submit / cancel form -->
<span ng-show="editableForm.$visible">
<button type="submit" class="btn btn-primary" ng-disabled="editableForm.$waiting">
Save
</button>
<button type="button" class="btn btn-default" ng-disabled="editableForm.$waiting" ng-click="editableForm.$cancel()">
Cancel
</button>
</span>
</div>
</form>
var app = angular.module("app", ["xeditable", "ngMockE2E"]);
app.controller('Ctrl', function($scope, $filter, $http) {
$scope.user = {
id: 1,
name: 'awesome user',
status: 2,
group: 4,
groupName: 'admin'
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.groups = [];
$scope.loadGroups = function() {
return $scope.groups.length ? null : $http.get('/groups').success(function(data) {
$scope.groups = data;
});
};
$scope.showGroup = function() {
if($scope.groups.length) {
var selected = $filter('filter')($scope.groups, {id: $scope.user.group});
return selected.length ? selected[0].text : 'Not set';
} else {
return $scope.user.groupName;
}
};
$scope.checkName = function(data) {
if (data !== 'awesome' && data !== 'error') {
return "Username should be `awesome` or `error`";
}
};
$scope.saveUser = function() {
// $scope.user already updated!
return $http.post('/saveUser', $scope.user).error(function(err) {
if(err.field && err.msg) {
// err like {field: "name", msg: "Server-side error for this username!"}
$scope.editableForm.$setError(err.field, err.msg);
} else {
// unknown error
$scope.editableForm.$setError('name', 'Unknown error!');
}
});
};
});