I defined my bootstrap tooltip like this:
<button popover-template="myPopoverTemplate.html" data-trigger="hover" popover-title="{{dynamicPopover.title}}" class="btn btn-default">Popover With Template</button>
my template looks like this:
<div>{{dynamicPopover.content}}</div>
<div class="form-group">
<label>Popup Title:</label>
<input type="text" ng-model="dynamicPopover.title" class="form-control">
</div>
Problem is the tooltip does not showup on hover?
plunkr ref:http://plnkr.co/edit/G1Cet74mVCkVYvdXRxnX?p=preview
Enabling sticky tooltip To make an element display its tooltip permanently, we use its showTooltipOn property. To make tooltip always be shown, set it to "always" .
Tooltip is a concept used in HTML for showing some extra information about the specifically selected element. This can be done on the mouse hover effect whenever the user moves the mouse over an element that is using a tooltip to display specified information about that element.
An example of a native browser tooltip is the way some browsers display an element's title attribute on long mouse hover. One cannot activate this feature through either keyboard focus or through touch interaction, making this feature inaccessible.
To make a simple tooltip, we'll first create the HTML element that triggers the tooltip when hovered over. We'll create this element as a div and assign it the class hover-text. Next, we'll create the element for the tooltip itself. This will be a span element with the class tooltip-text.
@Leeuwtje, in the plunkr reference that you have attached, there is a popover that is opening on mouseenter event (when you hover the mouse over the button).
The attribute to do that is not data-trigger="hover"
, but popover-trigger="mouseenter"
.
Also, for the template popover-template="dynamicPopover.templateUrl"
is added as an attribute to the element that triggers it.
Also, if you need to prefix the attributes with data-
, do them like this:
<button data-popover-template="" data-popover-trigger="" /></button>
The popover
prefixed to -template
or -trigger
in popover-trigger
and popover-template
makes it an angular ui directive, so removing popover-
would make it invalid / meaningless to angular ui.
EDIT
The reason the popover-template
did not work is because it expects a variable as the attribute value.
Replacing :
popover-template="myPopovertemplate.html"
by
popover-template="'myPopovertemplate.html'"
Adding the filename in quotes does the trick.
We put the template url in single quotes so it becomes a valid variable. That is why the other buttons on the page in the plunk function, because they have the popover-template
value to be variables that are defined in $scope
.
PLUNK : http://plnkr.co/edit/oEA5ekXDV5DSw6yoSHMd?p=preview
Hope this helped!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With