Search code examples
angularfrontendngx-bootstrap

ngx Bootstrap manual close button


I'm trying to make a a manual popover close button at the top right of the popover, using ngx-bootstrap. I do know that to add the x button, we would have to make use of &Times from bootstrap.

https://v4-alpha.getbootstrap.com/utilities/close-icon/

However I do not know how to implement it to my title as I am trying to add it to the top right.

 content: string = "content of popover ";
 Title: string = "Title of popover";
 <a [popover]="content" container="body" placement="top" [popoverTitle]="Title" >Making this popover</a>
              

enter image description here

This is the link I'm using. I'm using this example, the template and component.

enter image description here

My plunker basically, to put it simple, I need a X on the top right of the title.


Solution

  • Manage to do it eventually, since popoverTitle only accepts string

    <div>
      <ng-template #popoverContent3>
        <div style="font-size:18px; font-family:'Times New Roman'; font-weight:bold;">
          <p>this is a title...
          <button type="button" (click)='pop2.hide()' class="close" aria-label="Close">
          <span aria-hidden="true">&times;</span>
          </button>
          </p>
        </div>
        <div>
         <p>The best looking pop over, with a TITLE!</p>  
        </div>
      </ng-template>
      
      <a  [popover]="popoverContent3" #pop2="bs-popover" placement="right">
       Pop over with title and a x button!
        </a>
    </div>