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

Modify route title and component if user is authenticated

I've successfully implemented a login feature in my Nativescript-Vue application that utilizes the RadSideDrawer component. My current challenge is to change the route from 'Login' to 'Logout', and I'm struggling to find a wa ...

What is the best way to create a function that will return a Promise within an Express Route?

I am working with a business level database module named "db_location" that utilizes the node-fetch module to retrieve data from a remote server through REST API. **db_location.js** DB LOGIC const p_conf = require('../parse_config'); const db_ ...

Exploring Apache Zeppelin: Retrieve tabular data directly within your code block

In the latest version of Apache Zeppelin (0.8.0), users now have the ability to modify data in cells within the built-in table feature. It seems that these new values are connected to a variable within the Angular scope. Is there a way for me to determin ...

Enhancing speed on an extensive list without a set height/eliminating the need for virtualization

My webapp includes a feature that showcases exhibitors at an expo. The user can click on "Exhibitors" in the navigation bar to access a page displaying all the exhibitors. Each exhibitor may have different details, some of which may or may not contain data ...

Issue with integrating Google Spreadsheet as the data source for a Next.JS website: updates are not reflecting on the website pages

The website for this restaurant was created by me, using Google Spreadsheet to populate the menu pages. I chose this method for its simplicity and familiarity to the client. I'm utilizing the google-spreadsheet package to extract necessary informatio ...

Parsing URLs with Node.js

Currently, I am attempting to parse the URL within a Node.js environment. However, I am encountering issues with receiving null values from the following code. While the path value is being received successfully, the host and protocol values are returnin ...

Exporting a VueJS webpage to save as an HTML file on your computer

Scenario: I am working on a project where I need to provide users with the option to download a static export of a webpage that includes VueJS as a JavaScript framework. I attempted to export using filesaver.js and blob with the mimetype text/html, making ...

Invoking a PHP function within a JavaScript file

I'm facing an issue with calling a PHP function from JavaScript. I have written a code snippet where the PHP function should print the arguments it receives, but for some reason, I am not getting any output when running this code on Google Chrome. Can ...

Bidirectional binding within a directive cannot be assigned to a model from a service

An error message "{0}" is showing up when using directive "{1}", the details can be seen here: https://docs.angularjs.org/error/$compile/nonassign Update: I have resolved the issue by moving the config object into the scope, but the models are still not b ...

I need to find a way to swap out the bower package jsTimezoneDetect for an npm alternative

I am currently looking to remove bower from my repository, but I am encountering difficulties with replacing the package: "jsTimezoneDetect": "1.0.4". The recommended replacement for this package is "jstimezonedetect": "^1.0.6". Here is how I am using this ...

AngularJS returns two http get requests but only the first one gets resolved

I am a newcomer to angularjs and I am currently working on developing a mobile app using angularjs. I have encountered an issue where the if condition is functioning correctly, but the else condition is not. Specifically, the first http request is working ...

Unable to stop submission as a result of ajax verification

As someone new to java and jquery, I am facing a challenge with the code below: $(document).ready(function() { //Prevent SUBMIT if Session setting = On (Ajax) $('#formID').submit(function(e) { var prevent = false; $.ajax({ type: ...

Issues with displaying HTML5 audio player in iOS Chrome and Safari browsers

My html5/jquery/php audio player is working well on desktop browsers, but when I tried testing it on iOS, all I could see was a grey track bar. I suspect that the controls are hidden behind the track bar because sometimes the associated file starts playing ...

Struggling to form an array of arrays: encountering an issue with data.map not being a function

I have received some data in the following format: const mockData = [ { "1": [ { val1: 0.9323809524, val2: 5789.12, val3: 84.467, val4: 189.12, val5: 8, bins: 1, }, { ...

Creating a ROT13 cipher in JavaScript

In my JS function, I need to handle a variable called i. My goal is to encode this variable using ROT13 before proceeding with the function. The challenge lies in decoding the variable and integrating it into the script. I came across a JavaScript implem ...

Using JavaScript to search for a specific string within a row and removing that row if the string is detected

I need help with a script that removes table rows containing the keyword STRING in a cell. However, my current script is deleting every other row when the keyword is found. I suspect this has to do with the way the rows are renumbered after deletion. How c ...

The selected value is not displayed in the Material UI select component

My select component is showing the menu items and allowing me to select them, but it's not displaying the selected value. However, its handle function is functioning correctly because when I choose an item, the value in the database gets updated. Bel ...

Experienced an unexpected setback with the absence of the right-click capability on a Javascript-powered hyperlink, specialized for

I am facing an issue with a hyperlink on my website. This particular hyperlink submits a hidden form using the POST method to redirect users to another site. However, when someone right-clicks on this hyperlink and tries to open it in a new tab, they are o ...

Executing an http.get request in Angular2 without using RxJS

Is there a method to retrieve data in Angular 2 without using Observable and Response dependencies within the service? I believe it's unnecessary for just one straightforward request. ...

From creating a simple jQuery fiddle, let's delve into the world

Here is a code snippet I'm trying to transition from jQuery to an Angular directive. Visit this link to view the original code: http://jsfiddle.net/rhtr1w04/ Below is my implementation in app.js: angular.module('app',[]).directive('an ...