Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying dynamic data from AngularJS to Twitter Bootstrap Popover

I was attempting to get Bootstrap Popover to work with dynamic binded data in AngularJS with the AngularUI passthrough. In my fiddle i'm unable to dynamically show the title of office locations and list of people in each office: http://jsfiddle.net/stevenng/wmJtr/3/

like image 723
phteven Avatar asked Aug 14 '12 21:08

phteven


2 Answers

One way you can do this is by just referencing office in the ui-options like this fiddle:

<div ng-repeat="office in offices">
  <a href="" ui-jq="popover" ui-options="{title:office.location, content:office.people.join(',')}">Test Popover - {{office.location}}</a>    
</div>    

Another way you can do this is to generate the ui-options through a function passing in the current item into it like this fiddle.

With this html snippet:

<div ng-repeat="office in offices">
  <a href="" ui-jq="popover" ui-options="popoverOptions(office)">Test Popover - {{office.location}}</a>    
</div>

And this controller code:

$scope.offices = [
    {location:'Europe', people:['andy','gloopy']},
    {location:'USA', people:['shaun','teri']},
    {location:'Asia', people:['ryu','bison']}];

$scope.popoverOptions = function(office){
    return { title: office.location,
             content: office.people.join(',') };
}      
like image 162
Gloopy Avatar answered Nov 10 '22 23:11

Gloopy


We have few of the bootstrap components working here: https://github.com/angular/angular.js/blob/v1.0.x/src/bootstrap/bootstrap.js perhaps you can use it as inspiration for your popover?

like image 32
Misko Hevery Avatar answered Nov 11 '22 00:11

Misko Hevery