displaying a structured data grid in angularjs

My data is formatted in a json with the following rows:

{{"0":"94122","1":"94132","2":"94131","3":"94116","4":"94107"}
{"0":4,"1":2,"2":4,"3":2,"4":2}}

Using the code snippet below:

  <li ng-repeat="x in table">
  {{ x }}
   </li>

I am currently displaying the data as follows:

 {"0":"94122","1":"94132","2":"94131","3":"94116","4":"94107"}
 {"0":4,"1":2,"2":4,"3":2,"4":2}

I want to convert this into a tabular format like so:

  <tr ng-repeat="roll in sushi">
    <td>{{ roll.name }}</td>
    <td>{{ roll.fish }}</td>
    <td>{{ roll.tastiness }}</td>
  </tr>

Answer №1

<tr ng-repeat="item in data">
    <td ng-repeat="(key, val) in item">{{val}}</td>
</tr>

or

 <tr ng-repeat="item in data">
    <td>
        <p ng-repeat="(key, val) in item">{{val}}</p>
    </td>
 </tr>

or

 <tr ng-repeat="item in data">
    <td>
        <ul>    
            <li ng-repeat="(key, val) in item">{{val}}</li>
        </ul>
    </td>
 </tr>

Answer №2

Are you looking for something similar to this?

<tr ng-repeat="item in items">
    <td>{{ item["0"] }}</td>
    <td>{{ item["1"] }}</td>
    <td>{{ item["2"] }}</td>
    <td>{{ item["3"] }}</td>
    <td>{{ item["4"] }}</td>
  </tr>

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

tips for transforming contour data set from x/y/z coordinates to a three-dimensional object

I am working with a data set that includes x, y, and z values for a contour. I would love to hear your thoughts on how I can utilize this data to create a 3D representation in the world of webgl using three.js. ...

Incorporate a widget with dynamic height adjustment

We are currently working on creating a widget that can be easily embedded by third-party websites. Our goal is to have the widget automatically adjust its height through the embed script. Initially, we considered using an IFrame generated by our JavaScrip ...

Highcharts feature enhancement: Adjusting zIndex of legendItem on mouseover/mouseout

I have a chart that includes a 'total' sum value series alongside other values. My goal is to initially hide or place this 'total' column behind the others, and then bring it to the front when the series' legendItem is hovered ove ...

Filtering data using Mongoose to send specific information

Having a bit of code here // Script for retrieving pokedex data app.get("/pokedex", function (req, res) { Pokemon.find(function (err, pokemon) { if (err) { console.log(err); } else { console.log(pokemon ...

Is it possible to implement formvalidation.io in a React project that is using Materialize-css?

Can the formvalidation.io plugin be used with React and Materialize-css in a project? My project consists of multiple input components that may or may not be within a form. I want to utilize formvalidation for input validation. However, I am unable to find ...

Exporting Canvas data without the alpha channel

I am looking for a way to resize images that are uploaded in the browser. Currently, I am utilizing canvas to draw the image and then resize it using the result from the toDataURL method. A simplified version of the code (without the upload section) looks ...

Encountering an issue with NPM while attempting to install Parcel

After trying multiple solutions from various online sources, I am still unable to resolve the issue. Any advice or recommendations would be highly appreciated! npm ERR! code 1 npm ERR! path C:\Users\Tarun\Desktop\NamasteReact\node_ ...

Dynamically insert a new row into an HTML table using AJAX and refresh the table with .load method

I am facing an issue with my HTML table that loads data dynamically through a PHP snippet containing SQL queries. There is a Select option and a button on the table to add a new row, which triggers an AJAX procedure to send the data to PHP for insertion in ...

Obtain the orientation of the threejs scene and camera to establish the initial perspective

Currently, I am facing challenges in configuring the default camera position and orientation for my THREE.JS demo. I aim to manually adjust the view/scene/camera through trackball interaction and then find a way to set the correct camera settings to establ ...

Difficulty with making HTTP Requests in Node.js

It's like I'm stuck in a maze trying to find my way out. I could use some guidance on unraveling the mystery behind the appearance of "[object Object]" and understanding the error message. Any assistance in steering me towards the correct path w ...

Traversing an array in JavaScript to create a new array

I have a function that returns an array based on a condition. Here is the code snippet: const operationPerResource = (resource: ResourceTypes): OperationTypes[] => { const operations = cases[resource] || cases.default; return operations; }; Now, I ...

Cleaning up unwanted objects in THREE.js webGL

Our app utilizes THREE.js to showcase 3D body meshes. We have a special object named MeshViewer that manages the rendering process; within the initialize method, we establish this.renderer = new THREE.WebGLRenderer({ antialias: true, preserveDrawingBu ...

Generating a compilation using ng-repeat

HTML <html lang="en" ng-app="map" xmlns="http://www.w3.org/1999/xhtml"> <body> <div ng-controller="topbarController as topbarCtrl"> <div ng-repeat="pages in topbarCtrl.topbar"> {{pages.page}} </div> &l ...

Substitute numerical strings with actual numbers within an array

I need to transform an array from arr = ["step","0","instruction","1"] to newArr = ["step",0,"instruction",1] Below is the code I am using for this operation: newArr = arr.map((x) => { ...

just half of the four $_POST variables are actually assigned

Here is a simple form structure: <table class='table table-striped table-bordered table-hover' id='dataTables-example'> <thead> <tr> <th>1</th> <th>2</th> ...

A step-by-step guide on signing up users with django-rest-framework and angularJS

Working on a project to create a single page web app using AngularJS and Django. I've decided that all communication between the front and back end should be done through Django-REST. Currently focusing on user registration, but struggling with figu ...

Whenever I try to download express using npm install, I encounter a checksum

I currently have node version 0.10.30 and npm version 1.4.21 installed on my system. When I run the following command: npm install express I encounter the following error: Error: shasum check failed for /tmp/npm-4273-g1Rb0gCE/registry.npmjs.org/express/ ...

What is the best way to export assets into a React Native JS file?

After watching a video on YouTube, I noticed that at 3:20 the individual in the video quickly exported multiple assets into a file without providing any explanation. Can someone please view this specific moment in the video and clarify how this person mana ...

What is the best way to compile an array of permissible values for a specific CSS property?

One interesting aspect of the CSS cursor property is its array of allowed values, ranging from url to grabbing. My goal is to compile all these values (excluding url) into an array in JavaScript. The real question is: how do I achieve this without hardco ...

The requested resource in Angular 5 does not have the 'Access-Control-Allow-Origin' header present

I am currently utilizing angular 5 and attempting to execute the following web service getMethod() { let headers = new Headers(); headers.append('Access-Control-Allow-Origin', '*'); headers.append('Access-Control-Allow-Methods&ap ...