Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popover Template in Angular UI

I am using angular-ui-bootstrap in my current project, and I have a requirement for a popover to open up in each row in a grid displaying row specific information. The popover should have its own HTML template and there are multiple fields that can be bound in the HTML template. Here is the code I have written to achieve the same. I did try to pass the html template with no luck. Any help is appreciated.

HTML Code:

<div ng-app="helloAngular" ng-controller="casesCntrl">
  <table class="table table-bordered">
    <thead>
      <tr>
        <th class="">Date</th>
        <th class="">Case</th>                    
        <th class="">Severity</th>                
        <th class="">Status</th>
        <th class="">Site</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="case in cases">
        <td>{{case.casedate | date:'MM/dd/yyyy'}}</td>  
        <td><a ng-href="#/site/{{case.id}}">{{case.name}}</a></td>
        <td ng-class="{'case-critical':case.severity==1, 'case-urgent':case.severity==2, 'case-normal':case.severity==3}"  class="case-none"></td>  
        <td>{{case.status}}</td>    
        <td>{{case.sitename}}&nbsp;<button popover="{{case.sitename}}" popover-title="{{case.sitedescription}}"  data-placement="bottom" data-trigger="focus" class="btn btn-default" popover-unsafe-html="This is a Help but please <b> focus </b> on this">V</button></td>    
      </tr>
    </tbody>
  </table>      
</div>

JS Code:

function CasesController($scope) {    

var casesData = [
  {

    "name": "Case -1",
    "casedate":"2013-06-26T08:02:00-0700",
    "caseid":1,
    "severity": "1",
    "status":"New",
    "siteid":1,
    "sitename":"Merchant Demo 1"
  },
  {
    "name": "Case -2",
    "casedate":"2013-01-26T08:02:00-0700",
    "caseid":2,
    "severity": "1",
    "status":"New",
    "siteid":2,
    "sitename":"Merchant Demo 2"
  },
  {
    "name": "Case -3",
    "casedate":"2013-02-26T08:02:00-0700",
    "caseid":3,
    "severity": "1",
    "status":"Accepted",
    "siteid":1,
    "sitename":"Merchant Demo 3"
  } ,
  {
    "name": "Case -4",
    "casedate":"2013-05-26T08:02:00-0700",
    "caseid":4,
    "severity": "2",
    "status":"New",
    "siteid":1,
    "sitename":"Merchant Demo 4"
  } ,
  {
    "name": "Case -5",
    "casedate":"2013-09-26T08:02:00-0700",
    "caseid":5,
    "severity": "3",
    "status":"New",
    "siteid":1,
    "sitename":"Merchant Demo 5"
  } ,
  {
    "name": "Case -6",
    "casedate":"2013-04-26T08:02:00-0700",
    "caseid":6,
    "severity": "1",
    "status":"Sent to billing",
    "siteid":1,
    "sitename":"Merchant Demo 6"
  },
  {
    "name": "Case -7",
    "casedate":"2013-10-26T08:02:00-0700",
    "caseid":7,
    "severity": "3",
    "status":"New",
    "siteid":1,
    "sitename":"Merchant Demo 7"
  }
 ];
$scope.cases = casesData;
}

Here is the fiddle that has the same code as described above: http://jsfiddle.net/anirbankundu/YyK5s/4/

I did try the option by passing popover-unsafe-html as described in https://github.com/angular-ui/bootstrap/pull/641

like image 222
Anirban Avatar asked Feb 24 '14 08:02

Anirban


2 Answers

Can't be done right now, check the following issue for more details: https://github.com/angular-ui/bootstrap/issues/220

You can how ever use angular-strap to achieve the thing. Details are available at: http://mgcrea.github.io/angular-strap/##popovers

like image 98
Faisal Feroz Avatar answered Nov 15 '22 23:11

Faisal Feroz


The functionality to provide a template to a popover is introduced in angular UI bootsrap version 0.13.0 using popover-template attribute which takes the location of a template to use for the popover body. http://angular-ui.github.io/bootstrap/#/popover

like image 31
Ida N Avatar answered Nov 15 '22 23:11

Ida N