Exploring ways to display dynamic content within AngularJs Tabs

I need help figuring out how to display unique data dynamically for each tab within a table with tabs. Can anyone assist me with this?

https://i.stack.imgur.com/63H3L.png

Below is the code snippet for the tabs:

                        <md-tab ng-repeat="tab in tabs" label="{{tab.title}}">
                            <md-card layout="column" flex>
                                <md-tab-body>
                                    <md-table-container md-scroll-y layout-fill layout="column" class="md-padding table-scroll">
                                        <table md-table md-progress="promise" style="font-size: 11px !important;">
                                            <thead md-head md-order="query.order">
                                                <tr md-row>
                                                    <th md-column ng-repeat="tab in tabs track by tab.id"> {{ tab.content.Key }}</th>
                                                </tr>
                                            </thead>
                                            <tbody md-body>
                                                <tr md-row>
                                                    <td ng-repeat="tab in tabs track by tab.id" md-cell>{{ tab.content.Value }}</td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </md-table-container>
                                </md-tab-body>
                            </md-card>
                        </md-tab>
                    </md-tabs>

This is the function that retrieves the result:

function getSummaryReportSchema(transactionid) {
   transactionService.getSummaryReportSchema(transactionid, orgName)
        .then((result) => {
            var idx = 0;
            result.forEach((element => {
                var parsed = JSON.parse(element.Values.replace(/\r\n/g, ''));

                vm.masterDetailResults.push(parsed);
                vm.tabs.push({
                    id: idx++,
                    title: element.TaskName,
                    content: parsed
                });
            }));
        });
};

Here is the link to view the results stored in vm.tabs - https://gist.github.com/Taifunov/c75d6d3d7ed6a32c2e9fdae24f24ae22

Answer №1

You seem to have mixed up the variables in your ng-repeat loops. The first ng-repeat tab in tabs (should it be tab in vm.tabs instead?) assigns the variable tab that you use in your loop.

Then, when looping through the table cells, avoid iterating over tabs again - make sure to loop through tab.content instead.

<table md-table md-progress="promise" style="font-size: 11px !important;">
    <thead md-head md-order="query.order">
        <tr md-row>
            <th md-column ng-repeat="content in tab.content"> {{ content.Key }}</th>
        </tr>
    </thead>
    <tbody md-body>
        <tr md-row>
            <td ng-repeat="content in tab.content" md-cell>{{ content.Value }}</td>
        </tr>
    </tbody>
</table>

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

Creating a function that allows for the dynamic addition of rows in Angular with

I am currently working on implementing search and filter functionality, which requires adding rows dynamically. With hundreds of fields to filter, my boss has decided to organize them in dropdown menus (such as Manager, City, and Name in this example). The ...

Can you please explain how to indicate a modification in a JSON object with Polymer, transferring information from Javascript, and subsequently displaying child elements?

Currently, I am creating a JSON file that contains a random assortment of X's and O's. My goal is to display these elements in a grid format using a custom Polymer element. Initially, everything works fine as I can see a new grid generated each t ...

Issue encountered: Close functionality of Ionic popup not functioning as expected

I have developed an Ionic application that displays a popup window prompting users to rate the app if they have not done so previously. The Ionic popup is displaying correctly, however, the issue I am facing is that users have to click or tap the cancel bu ...

How can we leverage JavaScript to create logistic regression models for datasets and derive the beta-coefficients?

Exploring Logistic Regression in JavaScript In my current project, I am looking to fit a multi-variate logistic regression model to a dataset using JavaScript. My main goal is to extract the beta-coefficients for this model. Can anyone provide guidance on ...

What is the best way to extract data from the JSON response obtained from the Facebook Graph API in a Node

I am struggling to parse a JSON file in order to extract specific data, particularly the latest picture. How can I achieve this using Node.js and the Facebook Graph API? Below is the snippet of code I currently have: var params = { hostname: ' ...

Removing an element in JSON is resulting in an element that is undefined

Dealing with a JSON Object, I am faced with a challenge where deleting elements results in undefined entries, causing issues in my usage within datatables. Here is my current approach: function dTable(presId){ var allregos = '[{"presId": "a09N0000 ...

Refresh div content dynamically with anchor tag in place

I have a dilemma with the following div that contains an anchor tag linking to a php script responsible for updating information in a database and returning to this page. My goal is to execute this php script by clicking on the anchor tag, update the datab ...

What is the reason behind the cross-origin error thrown by JSON.parse?

When I don't use JSON.parse, my code works perfectly fine. However, as soon as I attempt to parse or stringify my data object, a cross-origin error is thrown. Why is this occurring and what steps can I take to resolve it? The snippet of code in Title ...

What is the best way to handle requests once a SpookyJS script has finished running?

Occasionally, I find myself needing to log in and extract some data from a specific website. To automate this process, I developed a CasperJS script that runs on Heroku. My goal is to create an endpoint like the following: app.get('/test', func ...

What is the reason behind the Typescript compiler not converting .ts files to .js files automatically?

Displayed below are the folders on the left showcasing my Typescript file in /src (blue) compiled into Javascript in /dist (purple) using tsc. https://i.stack.imgur.com/7XNkU.png In the source file on the left, there is a reference to a .ts module file t ...

Exploring the distinctions between Django template variables and JavaScript variables

I am currently trying to populate a table in a Django template. The challenge I am facing is comparing cell values between a JavaScript variable and a Django template variable within the same context. Is there a way to perform this comparison without conve ...

Error encountered: _moment2.default.date is not a recognized function within the React application

I keep encountering an issue when attempting to utilize a date from Moment.js in the constructor, componentWillMount, or componentDidMount. The error message I receive is: Uncaught TypeError: _moment2.default.date is not a function It's worth noting ...

Display a nested ng-repeat div based on certain conditions in Angular

<div class="sunti_display" ng-repeat="sunti in suntis track by $index"> <div class="individual_sunti" ng-click="update_ancestor(sunti)"> <!--requires a unique div#id using angular--> <div cla ...

Using JavaScript, display JSON data retrieved from a PHP file

Currently, I am in the process of developing a web application that displays tweets based on a city inputted by the user through an HTML form. The city value is stored in the $_SESSION['city'] variable after the form is submitted. Subsequently, ...

Dynamic jQuery URL truncater

Is there an on-the-fly URL shortener similar to Tweetdeck available? I have come across several jQuery and JavaScript plugins that can shorten a URL through services like bit.ly when a button is clicked. However, I am looking for one that shortens URLs aut ...

Error encountered while compiling NextJS: Unexpected use of single quotation mark in jsx-quotes

I can't seem to compile my NextJs 13 app without encountering errors. Take a look at my shortened eslintrc.js file below: module.exports = { env: { browser: true, es2021: true, }, extends: [ 'plugin:react/recommended', ...

Creating a function that counts the number of times a button is clicked

I want to have the "game" button appear after the user clicks the "next-btn" 2 times. Once the multiple choice test has been completed twice, I'd like the game button to show up and redirect the user to a separate HTML page called "agario.html." I&ap ...

Firestore implementing batching for realtime updates with the onSnapshot 'IN' condition

Summary I'm currently working on developing a Chat List feature similar to those found in major social networks. However, I'm facing challenges with managing state in React Native due to a common issue with Firestore involving the use of onSnaps ...

Position of JSON data response is inaccurate

Currently, I have a function that calls an API from the server in the following manner: getDataSet(callback) { request.open('POST', `${apiPath}`); request.setRequestHeader('Content-Type', 'application/x-ww ...

Bovine without Redis to oversee queue operations

Can Bull (used for job management) be implemented without utilizing Redis? Here is a segment of my code: @Injectable() export class MailService { private queue: Bull.Queue; private readonly queueName = 'mail'; constructor() { ...