Open Popover from Controller

I have created two popovers in the same page that have different templates.

The first one opens when I click a button and that works fine.
The second one I need it to open when users start typing in a search box, when I call $scope.searchPopover.show() it does not appear but adding the function on a button seems to work fine.

How can i fix this?

Can you show us your code?

Any error messages in the console?

If you can call the show function from a button, but not from the controller, then the problem probably isn’t with the popover but simply with however you’re calling the popover in the controller. For example the code that tracks if you start typing in a search box might not be registering correctly. e.g. if you switch out the .show() with a simple console.log, does it get called?

@abbara, i found what the problem is! If the popover is not attached to an element and you call showbfrom the controler as i was doing then it will mot open since it doesn’t know where to position itself.

Ive added a click event on the textfield and that solved it.

1 Like