How to display static JSON data in table in Angular ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In this article, we will see How to display static JSON data in the table in Angular. We will be displaying static data objects in Angular Table. We need to iterate over the object keys and values using key values and then handle them in the table. We will be using the bootstrap table and Angular PrimeNG Table template Steps for Installing & Configuring the Angular Application Step 1: Create an Angular application using the following command. ng new appname Step 2: After creating your project folder i.e. appname, move to it using the following command. cd appnameProject Structure It will look like the following: Example 1: In this example, we will use a normal bootstrap table to display the static JSON data. We will be iterating over the JSON object using keyvalue. HTML <!-- app.component.html --> <head> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <h2 style="color: green">GeeksforGeeks</h2> <h2> How to display static JSON data in table in Angular </h2> <table class="table table-striped" style="width:50%"> <thead> <tr> <th> Sr No. </th> <th> Course </th> <th> Cost </th> </tr> </thead> <tbody> <tr *ngFor="let item of gfg|keyvalue"> <td>{{item.key}}</td> {{set(item.value)}} <td *ngFor="let element of gfg2|keyvalue"> {{element.value}} </td> </tr> </tbody> </table> JavaScript // app.component.ts import { Component, OnInit } from '@angular/core'; import { KeyValue } from '@angular/common'; import { Pipe, PipeTransform } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: "./app.component.html", styleUrls: ['./app.component.css'] }) export class AppComponent { gfg: any = { "3": { "course": "Java", "cost": "1000" }, "4": { "course": "React", "cost": "1500" }, "2": { "course": "Angular", "cost": "1700" } , "1": { "course": "CSS", "cost": "800" } } gfg2: any set(obj: any) { this.gfg2 = obj } } JavaScript // app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HttpClientModule } from '@angular/common/http'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, HttpClientModule, ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } Output: Example 2: In this example, we will be rendering static JSON data in Angular. HTML <!-- app.component.html --> <div style="width:50%"> <h2 style="color: green"> GeeksforGeeks </h2> <h2> How to display static JSON data in table in Angular </h2> <p-table #myTab [value]="tableData"> <ng-template pTemplate="header"> <tr> <th>First Name</th> <th>Last Name</th> <th>Age</th> </tr> </ng-template> <ng-template pTemplate="body" let-people> <tr> <td> {{ people.firstname }} </td> <td> {{ people.lastname }} </td> <td> {{ people.age }} </td> </tr> </ng-template> </p-table> </div> JavaScript // app.component.ts import { Component } from '@angular/core'; interface People { firstname?: string; lastname?: string; age?: string; } @Component({ selector: 'app-root', templateUrl: './app.component.html', }) export class AppComponent { tableData: People[] = []; cols: any[] = []; constructor() { } ngOnInit() { this.cols = [ { field: 'firstname', header: 'First Name' }, { field: 'lastname', header: 'Last Name' }, { field: 'age', header: 'Age' }, ]; this.tableData = [ { firstname: 'David', lastname: 'ace', age: '40', }, { firstname: 'AJne', lastname: 'west', age: '40', }, { firstname: 'Mak', lastname: 'Lame', age: '40', }, { firstname: 'Peter', lastname: 'raw', age: '40', } ]; } } JavaScript // app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppComponent } from './app.component'; import { TableModule } from 'primeng/table'; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, TableModule, FormsModule, ], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule { } Output: Comment More infoAdvertise with us Next Article How to display static JSON data in table in Angular ? 21mcsrltd Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Questions Similar Reads How To Display Values With Interpolation In Angular? Angular is a powerful framework for building dynamic web applications. One of its key features is data binding, which allows developers to display and update values seamlessly within the UI. Interpolation is a fundamental technique in Angular that enables the integration of component data directly i 3 min read How to display output data in tabular form in Node.js ? Tables are a combination of rows and columns. Node.js has its own module named as a table that helps in making tables with a wide variety of styles that can be applied to the table such as border styles, colors body style, etc. Installation of module: npm install table Syntax: table(data, config) Pa 2 min read How to display the JSON data in EJS Template Engine ? EJS (Embedded JavaScript) is a templating language that allows dynamic content generation in NodeJS applications. It allows the integration of JavaScript code within HTML, making it easier to display dynamic data. To render JSON data in an EJS template, we can use EJS syntax to loop through the data 2 min read How to append a new table row in AngularJS ? In this article, we will see how to insert or append the new table row in AngularJS, along with knowing its implementation through the examples. Approach: The approach is to use the push() method to insert the new rows into the array. This array will be served as the content to the <tr> elemen 2 min read How To Set Width Of mat-table Column In Angular? In Angular Material, the mat-table component is a powerful data table tool that allows you to display data in a structured and flexible way. However, when it comes to customizing the appearance of the table, especially the width of individual columns, you may need to apply custom styling techniques. 4 min read How to print an array in table format using angularJS? Given an array & the task is to print the given array in the tabular format using AngularJS. In JavaScript, data can be stored in the form of arrays. Each of the array items has unique indexing, starting from 0. But what if the developer wants to display all the items that are in the array, on t 4 min read How to parse JSON Data into React Table Component ? In React parsing JSON Data into React Table Component is a common task to represent and structure data. We can render the JSON data into a table dynamically using the array map.Prerequisites:NPM & Node JSReact JSJSON parse()ApproachTo render JSON data in React Table we will be using the JavaScri 2 min read How to display data obtained from an API to Angular Material Card ? Angular Material is a UI component library that is developed by Google so that Angular developers can develop modern applications in a structured and responsive way. In this article, we will learn How to display data that is obtained from an API to a card of Angular Material. Steps for Installing 3 min read How to load data from JSON into a Bootstrap Table? This article describes how a Bootstrap Table is created using a given JSONÂ data. The data can be retrieved by either importing it or representing it in JavaScript. The following are given two methods to do it. Displaying JSON data without importing any file: The JSON file that has to be read can be 4 min read How to fetch data from JSON file and display in HTML table using jQuery ? The task is to fetch data from the given JSON file and convert data into an HTML table. Approach: We have a JSON file containing data in the form of an array of objects. In our code, we are using jQuery to complete our task. The jQuery code uses getJSON() method to fetch the data from the file's loc 3 min read Like