creating interactive tabs in angular using dynamic json values

Currently I am working on a material tab feature where I aim to dynamically generate tabs based on the values from my JSON data.

Below is the JSON data:

[
  {
    "regionName": "EMEA",
    "regionCurrency": "USD",
    "organizationName": "XYZ",
    "organizationSubName": "Miller",
    "Department": [
      {
        "DepartmentName": "Main",
        "FirstName": "David",
        "LastName": "Brown",
        "Band": 2,
        "Salary": 10000.00
      },
      {
        "DepartmentName": "Main 1", 
        "FirstName": "Marry",
        "LastName": "Brown",
        "Band": 2,
        "Salary": 10000.00
      }
    ]
  }
]

The generated tabs should display department names like this:

Main | Main 1

I am attempting to implement this using Angular Material tab component and here is the code snippet:

<mat-tab-group mat-align-tabs="start">
    <mat-tab *ngFor="let item of rowData.Department" label="{{rowData.DepartmentName}}"></mat-tab>
</mat-tab-group>

However, the tabs are not showing up in the modal. I would appreciate your feedback on whether my approach is correct or not. Thank you.

Answer ā„–1

appears to be a mistake in the binding

label="{{rowData.GroupName}}"

needs to be changed to

label="{{item.GroupName}}"

Answer ā„–2

In this case, rowData is actually an array and not an object. Therefore, in order to access the data within it, you will need to target specific elements within the array.

<mat-tab *ngFor="let item of rowData[0].Department" label="{{item.DepartmentName}}"></mat-tab>

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

What is the best way to define a signal within a class interface in Angular 17?

Iā€™m working on setting up signals for my properties in class, which has been going smoothly so far. public varName = signal(''); However, I would also like to utilize the related interface. Unfortunately, I have not come across any documentati ...

Troubleshooting Problems with Angular Localization in EJ2 Syncfusion

I have been utilizing the Syncfusion Spreadsheet component to display data similar to an Excel spreadsheet. I successfully implemented all the necessary functionalities with Syncfusion documents, however, I am encountering a challenge. My current issue i ...

Creating a Modern Application with MEAN stack utilizing Angular 2 and Angular-CLI

Currently, I am in the process of developing a MEAN app using Angular 2 and Angular CLI for building. Everything seems to be running smoothly as my GitHub repository can attest (link here). However, upon trying to access the page, I encounter multiple refe ...

Angular: Maximizing Output by Extracting Data from Outer and Inner Observables using RxJS

Subscribing to queryParams gives me the item code, but how can I retrieve data from both getItemDetails and getSecuredData at the same time? To avoid using multiple subscribe() functions, I have opted for the mergeMap operator. this.route.queryParams.pip ...

How can data be transferred between controllers in Angular 2 without using URL parameters or the $state.go() function?

I've encountered an issue where I need to pass a parameter from one controller to another without it being visible in the URL. I attempted to do so with the following code: this.router.navigate(['/collections/'+this.name], {id: this.id}); ...

Is it possible to replace checkboxes with dropdowns in the NG-ZORRO Tree component?

I am attempting to create a tree structure using the tree component from ng-zorro. However, instead of checkboxes for the leaf nodes, I would like to have dropdown menus. I tried using the ng-template but the checkbox is still appearing. Here is my code: ...

Testing Angular application with a currency pipe results in an error stating "currency

Utilizing the built-in angular currency pipe in my components works perfectly fine. However, when attempting to unit test my component, an error occurs: https://i.stack.imgur.com/J18JL.png I am using Angular 10 with Ivy and have imported the CommonModule, ...

How can I dynamically update content using <router-outlet> on a secondary page?

When accessing my homepage, I want to see a header, footer, and the home-news-page displayed. Additionally, when I click on a link in the header, I would like the content of the home-news-page to change accordingly. Here is how my routing is currently set ...

Angular workout with a handful of challenges

I'm struggling to complete an angular exercise that involves the following tasks: /* MAKE CHANGES TO THE CODE TO ACHIEVE THE FOLLOWING Activate the Band Name field only if all other fields are populated Update the bandName() validator so that it is ...

Establish the initial date for the calendar in ngb-datepicker

I am currently developing a calendar feature for an application using Angular 7. To display the calendar, I am implementing the ngb-datepicker component from angular ng-bootstrap library. My specific requirement is to be able to set a start date for the c ...

Angular 2 and its commitment

Currently, I am following the Angular 2 tutorial for the Hero App which includes a section on Http requests. You can find the tutorial here. In the hero.service.ts file, there is a method called getHeroes() that makes a call to the server: getHeroes(): ...

Issue with calling the component I've built in Angular

I recently developed a new component, but I am facing issues with it not appearing in the app. In my main component file (app.component.html), the code looks like this: <h1>First App</h1> <app-red-light></app-red-light> On the oth ...

Transforming the Server-side model to the Client-side model within Angular 4

My Server-side C# model public class Instructor:Entity { public string Name { get; set; } public string PhoneNo { get; set; } } Client-side TypeScript model export class Instructor extends Entity { public name:string; public address ...

Guide on converting a JSON object into a TypeScript Object

I'm currently having issues converting my JSON Object into a TypeScript class with matching attributes. Can someone help me identify what I'm doing wrong? Employee Class export class Employee{ firstname: string; lastname: string; bi ...

Invoke the method in customButton component of fullcalendar

I've integrated a custom button into my fullcalendar: ngOnInit() { this.calendarOptions = { customButtons: { custom1: { text: 'Add event', click() { this.openModal(); } } }, height: 600, editable: t ...

Sharing data between two Angular 2 component TypeScript files

I'm facing a scenario where I have two components that are not directly related as parent and child, but I need to transfer a value from component A to component B. For example: In src/abc/cde/uij/componentA.ts, there is a variable CustomerId = "sss ...

Send information to the main application component

Can data be passed two or more levels up from a Child Component to the App Component? https://i.stack.imgur.com/JMCBR.png ...

Issue with the integration of Angular and Java Jersey API arises when attempting to encode utf-8 whitespaces at the end, resulting in invalid JSON

I'm facing an issue with Angular while making an HTTP GET request. It throws a "Http failure during parsing" error because the JSON response contains whitespace characters at the end. I find it puzzling why the server is returning them. Is there a wa ...

Adjusting the settimeout delay time during its execution

Is there a way to adjust the setTimeout delay time while it is already running? I tried using debounceTime() as an alternative, but I would like to modify the existing delay time instead of creating a new one. In the code snippet provided, the delay is se ...

Guide on launching a bootstrap modal using ngIf

Hello everyone, I appreciate your patience as I am new to this! Currently, I am attempting to activate a Bootstrap modal using an ngIf condition. Specifically, the goal is for the modal to open when there is existing artwork present and allow for the addit ...