Search code examples
angularjsangular-ui-bootstrapbootstrap-popover

AngularJS: Stop page refresh on click of button which shows popover onclick


I am working on angularjs website and want to avoid page refresh on click of popover.Using bootstrap UI popover,to display list of actions. Page reload for the very first click on popover.

My html file:

<button ng-click="openTemplate($event)" uib-popover-template="searchPopover" 
  popover-placement="left" type="button" class="btn btn-default" 
  popover-trigger="focus">Actions
</button>

My controller.js:

$scope.openTemplate=function(event){
    event.preventDefault();
}

Solution

  • The simplest solution would be to use an <a> tag, instead of <button>, without the href attribute.