2

I am trying to open the popover dynamically by setting popover-is-open property to true dynamically from the controller like this:

    var el = angular.element(target.id); //popover attached to this element
    el.attr('popover-is-open',true) //setting attribute to true
    $compile(el.contents())($scope) //recompiling
    $scope.$digest();//running digest

Here is the html

<div id="taskcard-{{task.externalId}}" 
     popover-append-to-body="true" 
     popover-trigger="'none'" 
     popover-is-open="false"
     uib-popover-template="templateurl" 
     popover-title="testing">
          POPOVERS
</div>

Now, this doesn't work. Is there any other way around this?

2
  • can you please post full code including html here Commented Nov 29, 2017 at 3:30
  • @jitender check above Commented Nov 29, 2017 at 3:34

1 Answer 1

2

You can use some Boolean flag instead something like task.popoverIsOpen in popover-is-open attribute and can set it to true or false to open/close popover something like

 <div id="taskcard-{{task.externalId}}" 
     popover-append-to-body="true" 
     popover-trigger="'none'" 
     popover-is-open="task.popoverIsOpen"
     uib-popover-template="dynamicPopover.templateUrl" 
     popover-title="testing">
          POPOVERS
</div>

Set popoverIsOpen to true when you need

task.popoverIsOpen=true;

Working demo

Sign up to request clarification or add additional context in comments.

7 Comments

can't use it. i have like 100 popovers! can't maintain separate flag for each. And if i keep only one flag, all the popovers will open and close together :)
you mean to say you are using it inside ng-repeat of tasks right?
actually i have a requirement that all only one popover should be open at a time. So in your plunker user can have all the popovers open.
@beNerd check out update plunker
there is still a issue: instead of ng-click, I need to use ng-mouseenter and popover should be removed on mouseleave. i tried replacing ng-click with mouseenter but the popover doesn't disappear on mouseleave
|

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.