AngularJS: Utilizing nested ng-repeats for dynamic data rendering

Currently, I am utilizing the ng-repeat directive in conjunction with the ng-repeat-start/ng-repeat-end options. Within the main loop, there is an additional inner ng-repeat. However, the problem lies in the fact that the outer ng-repeat-start declaration serves solely as a looping mechanism and I do not actually need to repeat the HTML element on which it is declared. Below is an example:

<tbody>
    <tr ng-repeat-start="anArray in arrayOfArrays">  <!-- HOW TO REMOVE THIS EMPTY <tr>? -->

    </tr>

    <tr ng-repeat="item in anArray ">
        <td>{{item .name}}</span></td>
        <td>{{item .surname}}</td>
    </tr>

    <tr ng-repeat-end>
        <td>
            <span>Total</span>
        </td>
    </tr>
</tbody>

I am seeking a way to remove the <tr> element while still maintaining the loop declaration.

I attempted to declare both loops (outer and inner) within the same <tr> element, but this approach did not prove successful:

<tr ng-repeat-start="anArray in arrayOfArrays" ng-repeat="item in anArray ">          
  </tr>

Answer №1

If you need to replicate all elements in the outer loop, you can achieve this by using the <tbody> tag for repetition. See code snippet below:

<tbody ng-repeat="anArray in arrayOfArrays">
    <tr ng-repeat="item in anArray ">
        <td>{{item .name}}</span></td>
        <td>{{item .surname}}</td>
    </tr>
    <tr>
        <td>
            <span>Total</span>
        </td>
    </tr>
</tbody>

If your goal is to duplicate only the inner loop and display the total once, consider splitting your table into two sections as shown below:

<tbody ng-repeat="anArray in arrayOfArrays">
    <tr ng-repeat="item in anArray ">
        <td>{{item .name}}</span></td>
        <td>{{item .surname}}</td>
    </tr>
</tbody>
<tfooter>
      <tr>
        <td>
            <span>Total</span>
        </td>
      </tr>
</tfooter>

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

Implementing AngularJS ng-click to dynamically add a duplicate Div or Widget with every click

The code below showcases a series of divs displayed one after the other: <ul class="record"> <li id="{{record.id}}" ng-repeat="record in records"> <div> Widget Code.... </div> </li> </ul> In addition to th ...

Calling Number() on a string will result in returning a value of NaN

Currently, I am working on the following code snippet: app.put("/transaction/:value/:id1/:id2", async(req,res) => { try { const {value,id1,id2} = req.params; const bal1 = await pool.query("Select balance from balance where id=$1",[i ...

Is it possible for jQuery datepicker to choose a date over a decade in the past?

Recently, I encountered an issue with jQuery-UI's datepicker where it was restricting me to select birthdays only within the last 10 years. This basically meant that users older than 10 years couldn't be accommodated :) I attempted to override t ...

Inspecting the Ace Editor within the onbeforeunload event handler to confirm any modifications

I'm attempting to utilize the $(window).on('beforeunload', function(){}); and editor.session.getUndoManager().isClean(); functions within the ace editor to detect whether a user has made modifications to a document without clicking the submi ...

The installed Bower component is not being referenced in the index.html file

I have successfully integrated lodash using bower into my angularjs application: bower install --save lodash The bower.json file has been updated with the necessary dependencies: { "name": "my-app", "version": "0.0.0", "dependencies": { "lodas ...

Having an issue with my code in angular 12 where I am unable to successfully call an API to retrieve a token, and then pass that token to another API for further processing

Here is the code snippet containing two methods: getToken and validateuser. I am fetching the token from getToken and passing it as a parameter to validateuser. However, before retrieving the token, my second API call is being executed. ...

Creating designs on the canvas

With this code snippet, I have the ability to create lines using mouse points on a canvas. My goal is to identify when these lines connect to form a shape and then fill that shape with color. <script language="javascript" src="//ajax.googleapis.com/a ...

What is the method for retrieving the values of multiple numbers entered in table rows using ASP?

I am trying to customize an input field so that the client can add or delete N number of input fields as needed. While I have successfully implemented adding input fields, I am facing difficulty in retrieving values from these dynamically added text fields ...

Guide to creating a dictionary array on-the-fly:

I have been working on updating years to make it more dynamic by using the starting year (2010) and ending year (2018). Originally, I used a for loop to address this, but I am curious if there is a more efficient way to refactor years. Current arrangemen ...

Fulfill the promise once the callback has been triggered

In my code, I am working on preventing the method _saveAddress from being executed multiple times. To achieve this, I have created a promise for the method. const [pressEventDisabled, setPressEventDisabled] = useState(false); <TouchableOpacity style={s ...

Automatically bring in functions in JavaScript without explicitly declaring them

I am working with 2 files. //main.js const one = (text) => { return text; } const two = (text) => { return text + " is here"; } module.exports = [ one, two ] //app.js const data = require("./main.js"); console.log(data.one("exampl ...

Embracing JQuery for Frontend Development with Node.js

I'm currently enhancing my node.js skills by utilizing express, and I've encountered a situation that is causing me some confusion. Essentially, when a user requests a webpage and the backend sends them the HTML page, how can I incorporate a Java ...

How can I use JavaScript to sort through an array and organize the data into groups?

Below is an array that I currently have: Status=["active","inactive","pending","active","completed","cancelled","active","completed"] I am looking to achieve the following result: StatusInfo=["active":3,"inactive":2,"pending":1, "completed":2, "cancelle ...

Observing changes in Angular.js components when binding values from services to HTML

Is there a way to bind the changing HTML value from a service in my component? The value from the service is dynamic, but my component does not observe it. I simply want to display this variable as text in my component's HTML. Here is an example setu ...

What methods can be used to reveal the true value of data that has been encrypted?

Is it possible to retrieve the original value of data that has been hashed? Can the hashcode be reversed to reveal the real value of the data? String ida = new String(txtID.getText().toString()); int idb = ida.hashCode(); codeD.setText("result: " + ida) ...

What is the best way to upload this file in VueJS?

I've come across a file written in outdated syntax that I need to use in a VueJS Component. You can find the file here. For instance, consider these snippets from the file: var CCC = CCC || {}; CCC.STATIC = CCC.STATIC || {}; CCC.STATIC.TYPE = { & ...

trouble encountered while sending data to php using ajax and json

Despite trying multiple solutions, my script is still not working properly. It functions without the $_POST value and without JSON, but when both are included, it fails to work. The error message displayed by the function is as follows: <b>Notice< ...

What is the process for setting up a vertical carousel in Bootstrap 5 with a stationary previous image?

Looking for assistance with my vertical carousel project. Is there a way to create a vertical carousel in bootstrap 5 with the previous image fixed? I found a slider on this website: zara.com/jp/en/ I want to maintain the previous image in a fixed posit ...

Executing the executeScript method in Microsoft Edge using Java and WebDriverWould you like a different version?

I'm currently attempting to execute the following code in Microsoft Edge using WebDriver ExpectedCondition<Boolean> jsLoad = driver -> ((JavascriptExecutor) driver).executeScript("return document.readyState").toString().equals(&quo ...

What are the best methods for testing a function containing multiple conditional statements?

I have a complex function that I want to showcase here, it's quite simple but for some reason, I'm struggling with writing unit tests for it. I don't need the exact unit test implementation, just a general approach or tips on how to handle i ...