Create Hoverable popover using angular-ui-bootstrap

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

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



        
11条回答
  •  半阙折子戏
    2020-12-09 10:48

    I needed to do this as well. I have a checkbox in a table cell that can have 3 possible states: Enabled, Disabled, or Special case. The UI spec I have asked for a popover over the box that shows either of those statuses, or for the special case a sentence with a link.

    I tried several of these solutions and one of them worked for me, and they all added extra code. After some playing around, I determined I could just add the "popover-popup-close-delay" attribute with a dynamic value. So this works for me:

    
        
        
    
    

    Some context: My table is looping over an array of data objects, so ele is a single object. The getPopoverTxt() is just a simple method in my controller that returns one of the 3 labels I want to show ("Enabled", "Disabled", or "Special Text with HTML"). Its not necessary here, but the takeaway is to get the HTML to work, you have to wrap the string value in $sce.trustAsHtml(), like:

    var specialText = $sce.trustAsHtml('Text with a link to contact support');
    

    The rest is all the usual popover and form input settings we normally use. The "popover-popup-close-delay" is the key.

提交回复
热议问题