Create Hoverable popover using angular-ui-bootstrap

后端 未结 11 1029
渐次进展
渐次进展 2020-12-09 10:45

I have the following code for creating a popover in my template file:



        
相关标签:
11条回答
  • 2020-12-09 10:59

    Easiest way to have a mouse-event using uib-popover Look at the below working example ! You need not have a uib-tabset, I faced an issue with uib-tabset and so added that example.

    <uib-tabset>
          <uib-tab>
            <uib-tab-heading>
              Tab 1
            </uib-tab-heading>
            <div>
    
              <span ng-mouseover="popoverIsOpen = true" 
                    ng-mouseleave="popoverIsOpen = false">
                <button uib-popover-template="'includeFile.html'"
                        popover-trigger="outsideClick" 
                        popover-is-open="popoverIsOpen"
                        popover-placement="right"
                        type="button" class="btn btn-default">
                  Dynamic Popover
                </button>
            </span>
    
            </div>
            <p> tab 1</p>
          </uib-tab>
          <uib-tab>
            <uib-tab-heading>
              Tab 2
            </uib-tab-heading>
    
            <p> tab 2</p>
          </uib-tab>
        </uib-tabset>
    

    Template: includeFile.html

    <div>
      <span>This is for tesitng</span>
      <strong> <a href="www.google.com">www.google.com</a></strong>
    
    </div>
    
    0 讨论(0)
  • 2020-12-09 11:04

    html

     <span class="icon-globe" id="visibilityFor" popover="hello how are you" 
           popover-placement="right" popover-trigger="mouseenter" 
           popover-popup-delay="50" viz>
    </span>
    

    directive

    myAppModule.directive('viz', function ($rootScope,$timeout){
        return{
    
            restrict:"A",
            link: function (scope, element, attrs) {
                $rootScope.insidePopover = false;
    
                element.bind('mouseenter', function (e) {
                    $timeout(function () {
                        if (!$rootScope.insidePopover) {
                            element.popover('show');
                         //  attachEvents(element);
                        }
                    }, 200);
                });
    
                element.bind('mouseout', function (e) {
                    $timeout(function () {
                        if (!$rootScope.insidePopover) {
                            element.popover('show');
                         //   attachEvents(element);
                        }
                    }, 200);
                });
    
            }
        }
    });
    

    Note : - Don't forget to include angular-strap after jQuery.js & angular.js

    0 讨论(0)
  • 2020-12-09 11:05

    There I spend 1 day and finally get solution.

    <button uib-popover="{{dynamicPopover.content}}" 
        popover-trigger="outsideClick" popover-is-open="popoverIsOpen"
        ng-mouseenter="popoverIsOpen = !popoverIsOpen" 
        popover-title="{{dynamicPopover.title}}" type="button" class="btn btn-default">Dynamic Popover</button>
    

    Please check Plunkeer Link Check only Dynamic Popover button code

    Thanks,

    0 讨论(0)
  • 2020-12-09 11:06

    This feature was added in Angular UI Bootstrap 0.14.0 and is documented here. Disable the triggers and use the popover-is-open property to manually dictate the opened/closed state.

    0 讨论(0)
  • 2020-12-09 11:10

    What I did that gets my by in 0.13.X is to set the element to be hoverable to a <button> and then set the popover-trigger="focus". Then style the button how you wish, and focus the button by clicking it. You can hover in the popover and click a link, all I need to do.

    0 讨论(0)
提交回复
热议问题