Issues with ng-repeat not functioning properly within a Popover

I have a list that I am looping through using ng-repeat:

<div class="row msf-row" ng-repeat="record in recordlist people-popover>
   <div class="col-md-1 msf-centered" ng-show="editItem == false" ng-hide="editItem">
      <button class="btn btn-primary form-control msf-paxlist" rel="popover" data-content="<li ng-repeat='passanger in record.pax'>{{passanger.name}}</li>" data-original-title="Passenger List">
          {{record.pax.length}} <i class="fa fa-user"></i>
      </button>
   </div>
</div>

To enable the popover, I have created a directive:

.directive('peoplePopover', function() {
    return function(scope, element, attrs) {
        element.find("button[rel=popover]").popover({ placement: 'bottom', html: 'true'});
    };
})

The issue lies in the

<li ng-repeat="passanger in record.pax">{{passanger.name}}</li>
section, which is not displaying properly.

If I use

<li ng-repeat="record.pax">{{pax}}</li>
, it only displays the array and not the individual objects within it.

Here is an example of how the 'record' array looks:

record in recordlist {
    date: "02/12/2014",
    time: "00.02.01",
    car: "369",
    pax: [
        {
        name: "Ben",
        chosen: true
        },
        {
        name: "Eric",
        chosen: true
        }
    ]
}

Any suggestions on how to properly display the objects within the 'record.pax' array?

Answer №1

When faced with a similar issue, I came up with a solution.

What I did was encapsulate the ng-repeat block within another directive and passed the collection to that external directive.

div class="row msf-row" 
     ng-repeat="record in recordlist 
     people-popover>
       <div class="col-md-1 msf-centered" ng-show="editItem == false" ng-hide="editItem"> 
          <button class="btn btn-primary form-control msf-paxlist" 
                  rel="popover" 
                  data-content="<new-directive records=record.pax></new-directive>" 
                  data-original-title="Passanger List">
              {{record.pax.length}} <i class="fa fa-user"></i>
          </button>
       </div>
</div>

Within the new directive, this is the code you will find.

<li ng-repeat='passanger in record.pax'>
         {{passanger.name}}
</li>

I hope this solution will be beneficial to others facing a similar challenge.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Configuration object for Webpack is not valid

I encountered an error while using webpack that says: Invalid configuration object. Webpack has been initialized with a configuration object that does not conform to the API schema. - configuration.resolve has an unknown property 'extension&ap ...

Discover the new features of Next.js 13: Learn how to efficiently extract parameters from URLs using userParams, and seamlessly pre-render components at build time

Currently, I am diving into the latest version of next.js 13.4 and have set up a page with the route /notes/[note]. To extract the note parameter from the URL, I am utilizing import { useParams } from 'next/navigation'. In addition to this, I wa ...

Struggling with textpath SVG elements in jQuery

Currently, I am implementing SVG in my project and aiming to apply the toggleClass function using jQuery on the textpath elements upon clicking. My initial plan was: $("text#names > textpath").click(function() { $(this).toggleClass("newClass"); }) ...

Using ReactJS and react-router to exclude the navigation menu on the login page

I have a LoginPage designed like this: https://i.sstatic.net/yzovV.png After logging in, you will be directed to this page: https://i.sstatic.net/pZFou.png Now, I want the login page to have no navigation and look like this: https://i.sstatic.net/1sH9v ...

Finding the Client's Private IP Address in React or Node.js: A Comprehensive Guide

Issue I am currently facing the challenge of comparing the user's private IP with the certificate's IP. Is there a method available to retrieve the user's private IP in react or node? Attempted Solution After attempting to find the user&a ...

The function for fetching JSON data using AJAX is not functioning properly

Can someone help me troubleshoot why my code isn't working to retrieve a JSON file from a PHP page? Here is my PHP page: header('Content-type: application/json'); $jsonstart="{'files' : ["; $jsonend="]}"; $content="{'fir ...

Error message: "Module not found" encountered while executing test case

I am a beginner in node and nightwatch and I have followed all the initial instructions from setting up node, npm, selenium standalone, starting the selenium driver. I also downloaded the chrome driver and placed it in the same directory. I created the con ...

The type '{}' cannot be assigned to type 'IntrinsicAttributes & FieldsProp'. This error message is unclear and difficult to understand

"The error message "Type '{}' is not assignable to type 'IntrinsicAttributes & FieldsProp'.ts(2322)" is difficult to understand. When I encountered this typeerror" import { useState } from "react"; import { Card } fr ...

Send the parameter to the compile method within the directive

I am currently working on creating a generic field and utilizing a directive for it. In my HTML code, I have defined the following: <div def-field="name"></div> <div def-field="surname"></div> <div def-field="children"></d ...

When a user clicks on a specific element's id, the image will rotate accordingly

When the elements in ul are clicked, the image rotates. The default position of the image is already rotated by a certain number of degrees, and on each click, it rotates to the desired value. This was achieved using the following code: $("#objRotates"). ...

execute a setTimeout function in ReactJs to render a component after a specified amount of time

Is there a way to render a component inside my App.Js after a certain amount of time using setTimeout? I've tried, but nothing seems to be happening... This is my code: function App() { return ( <Router> <GlobalStyle /> ...

Integration of a QR code scanner on a WordPress website page

I'm in the process of setting up a QR code scanner on my Wordpress site or within a popup. The goal is for users to be able to scan a QR code when they visit the page/popup link. Specifically, the QR code will represent a WooCommerce product URL, and ...

Changing the data of a child component that is passed through slots from a parent component in Vue.js

Exploring the world of components is new to me, and I'm currently trying to understand how the parent-child relationship works in components. I have come across component libraries that define parent-child components, such as tables and table rows: &l ...

Activate hashbang in the AngularJS $http URL

I have been attempting to access a URL using AngularJS like this: $http.get("http://localhost:8080/#/notebook/2CG2BVYJ1") .then(function(response){ vm.getgraph = response.data; }); However, it seems that the get request only sends http:// ...

Issues with voice state updates in JavaScript

I am currently working on setting up a discord bot to send notifications when someone joins a voice chat. While coding in Atom, I encountered the following error: TypeError: Cannot read property 'send' of undefined at Client.client.on (C:\U ...

Having trouble with RethinkDB filter not returning any matches?

Encountering an obstacle with RethinkDB while using NodeJS. Attempting to utilize a basic .filter() function, but for some mysterious reason, it fails to retrieve a result. The current code snippet in question looks like this: const someID = 1234; ...

Toggle the visibility of a div based on the id found in JSON data

I am looking to implement a JavaScript snippet in my code that will show or hide a div based on the category ID returned by my JSON data. <div id="community-members-member-content-categories-container"> <div class="commun ...

What strategies can be employed to streamline the code provided?

Can someone help simplify this JavaScript code for me? I would really appreciate it. Thank you! $(function() { $("#show1").click(function() { $("#showmore1").toggle(); }) $("#show2").click(function() { $("#showmore2").toggle(); ...

"Utilizing JSON.parse() to convert a string captured from a PythonShell back

Using PythonShell in Node to execute a Python script that generates a Python dict, such as: { "playedStatus": game['playedStatus'].encode('ascii'), "awayTeamAbb": game['awayTeamAbb'].encode('ascii'), "homeTeamAbb": ...

The Ionic AngularJS http service is failing to update the controller

I'm struggling to understand why my controller is receiving an empty array after calling the service, which triggers an http call. Here's how I have set up my app: Here is my app.js file: //App.js .state('myApp.sermonlists', { u ...