2

How do I add custom placements/animations to an AngularJS/Bootstrap tooltip? I can do:

myApp.controller('TooltipCtrl', function ($scope) {
  $scope.htmlTooltip = 'Here is a tooltip!';
});

And it works perfectly, but if I add:

$scope.setTriggers({
  placement: 'right'
});

inside the controller, I get an "undefined is not a function" error. What am I syntactically doing wrong?

EDIT:

I also tried doing this:

myApp.controller('TooltipCtrl', function ($scope) {
  $scope.placement = 'right';
  $scope.htmlTooltip = 'Here is a tooltip!';
});

but it seems to have no effect on the placement on the tooltip.

2 Answers 2

10

If you are trying to configure of the "$tooltipProvider".

$tooltipProvider is a provider hence configurable only in the CONFIG Phase of angular.

You will have to try it setting it in the CONFIG Phase of angular.

    angular.module('yourApp', ['ui.bootstrap'])
        .config(['$tooltipProvider', function ($tooltipProvider) {
        $tooltipProvider.options({
            placement: 'right'
        });
    }])
5
  • Syntactically what you just posted is incorrect.. you have an extra bracket and stuff. Also why are you using = instead of :? It says on the Angular BootStrap UI to use the line placement: 'right', I'm just not sure how to incorporate it into the controller. Commented Jun 9, 2014 at 19:28
  • See stackoverflow.com/questions/19730461/…. Do I have to add something to my routes.js? Commented Jun 9, 2014 at 19:31
  • 1
    @Hubrid $tooltipProvider.options sets the default for tooltips. From your question, it sounds like you're looking for "custom placements" (emphasis is mine), meaning not the defaults but config for individual tooltips. Is that me just misunderstanding your wording?
    – Marc Kline
    Commented Jun 9, 2014 at 19:40
  • I see that you've changed it, but you have in such a way that sets the defaults for tooltips. What I'm asking the OP is whether this is truly what they want, because their original question is ambiguous but seems to indicate that it's not.
    – Marc Kline
    Commented Jun 9, 2014 at 19:52
  • Either way works. I meant individual tooltips originally, but I think all of my tooltips will have the same right placement, so it doesn't matter practically. That being said, I'm still interested in how you would set individual defaults. Commented Jun 9, 2014 at 19:59
2

Angular $tooltipProvider has been changed to $uibTooltipProvider. Try this.

angular.module('yourApp', ['ui.bootstrap'])
.config(['$tooltipProvider', function ($uibTooltipProvider)
{
   $tooltipProvider.options({
   placement: 'right'
  });
}]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.