Hide Angular UI Bootstrap popover when clicking outside of it

UPDATE: With the 1.0 release, we’ve added a new trigger called outsideClick that will automatically close the popover or tooltip when the user clicks outside the popover or tooltip. Starting with the 0.14.0 release, we’ve added the ability to programmatically control when your tooltip/popover is open or closed via the tooltip-is-open or popover-is-open attributes.

How to create an angularJs wrapper directive for a ui-bootstrap datepicker?

To be honest, I’m not quite sure why it’s caused and what’s causing your date to be “toString-ed” before showing it in the input. However, I did find places to restructure your directive, and remove much unnecessary code, such as $compile service, attributes changes, scope inheritance, require in the directive, etc.. I used isolated scope, … Read more

Is there a way to automatically close Angular UI Bootstrap modal when route changes?

If you want all the opened modals to be closed whenever a route is changed successfully, you could do it in one central place by listening to the $routeChangeSuccess event, for example in a run block of your app: var myApp = angular.module(‘app’, []).run(function($rootScope, $uibModalStack) { $uibModalStack.dismissAll(); }); Here you can see that the $uibModalStack … Read more

Angular bootstrap datepicker date format does not format ng-model value

Although similar answers have been posted I’d like to contribute what seemed to be the easiest and cleanest fix to me. Assuming you are using the AngularUI datepicker and your initial value for the ng-Model does not get formatted simply adding the following directive to your project will fix the issue: angular.module(‘yourAppName’) .directive(‘datepickerPopup’, function (){ … Read more

Avoid having to double-click to toggle Bootstrap dropdown

If someone is using angular with ui-bootstrap module along with normal bootstrap HTML dropdown definition, there are also two clicks needed. <li class=”dropdown”> <a href=”#” class=”dropdown-toggle” data-toggle=”dropdown”>Dropdown</a> […] </li> => Removing the data-toggle=”dropdown” will fix the issue. Opening the dropdown with one click will work after this. Reference: https://github.com/angular-ui/bootstrap/issues/2294

Mocking $modal in AngularJS unit tests

When you spy on the $modal.open function in the beforeEach, spyOn($modal, ‘open’).andReturn(fakeModal); or spyOn($modal, ‘open’).and.returnValue(fakeModal); //For Jasmine 2.0+ you need to return a mock of what $modal.open normally returns, not a mock of $modal, which doesn’t include an open function as you laid out in your fakeModal mock. The fake modal must have a result … Read more

Best way to combine AngularJS and Twitter Bootstrap

Generally, the CSS part of Bootstrap works exactly the same way with AngularJS as it works with the Bootstrap JavaScript. So as long as you only want to use Bootstrap CSS, you do not have to think about it. For almost all of the Bootstrap JavaScript functionality, AngularUI provides an alternative approach. E.g. the navbar … Read more