code: function PopoverController($scope) {
    /**
     * The state of the popover (displayed or not)
     * @type {boolean}
     */
    this.shown = false;
  
    /**
     * @type {?JQuery}
     */
    this.anchorElm = null;
  
    /**
     * @type {?JQuery}
     */
    this.bodyElm = null;
  
    const clickHandler = (clickEvent) => {
      if (!this.anchorElm) {
        throw new Error('Missing anchorElm');
      }
      if (!this.bodyElm) {
        throw new Error('Missing bodyElm');
      }
      if (this.anchorElm[0] !== clickEvent.target &&
        this.bodyElm.parent()[0] !== clickEvent.target &&
        this.bodyElm.parent().find(clickEvent.target).length === 0 && this.shown) {
        this.dismissPopover();
      }
    };
  
    document.body.addEventListener('click', clickHandler);
  
    $scope.$on('$destroy', () => {
      document.body.removeEventListener('click', clickHandler);
    });
  }
docs: The controller for the 'popover' directive.
  @constructor
  @ngInject
  @ngdoc controller
  @ngname NgeoPopoverController
  @param {angular.IScope} $scope Scope.
  @private
  @hidden