Arranging json array according to alphabetical sections in angularjs 2

In the example below, I am working with JSON data that needs to be formatted and placed in a box according to specific criteria. The data sorted in A-B should go to a particular section, and it needs to be dynamic. Despite numerous attempts, I have not been successful in achieving this. https://i.sstatic.net/KamTp.png

Unfortunately, the question does not provide any details about the code. I apologize if the question is not presented in the correct order. This is the logic that needs to be implemented based on visual requirements.

Answer №1

This is the division that iterates through each individual division. I have utilized simple div elements to create seven columns in a single row. Below you will find app.component.html

<div class="alphacolumn" *ngFor="let alpha of alphacustomer">
    <p class="sort">{{alpha.order}}</p>
    <div class="cus-box" *ngFor="let custo of alpha.data">
        {{custo.customer}}</div>
    </div>

app.component.ts

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.scss']
})
export class SearchComponent implements OnInit {
  alphacustomer:any[];
  slectedCustomer:any;
  constructor() { 
    this.alphacustomer=[
      {
        order:"A-B",
        data:[
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNames"},
        ]
      },
      {
        order:"C-E",
        data:[
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNames"},
        ]
      },
      {
        order:"F-L",
        data:[
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNames"},
        ]
      },
      {
        order:"M-P",
        data:[
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNames"},
        ]
      },
      {
        order:"Q-S",
        data:[
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNames"},
        ]
      },
      {
        order:"T-Z",
        data:[
          {customer:"CountryNames"},
          {customer:"CountryNames"},
          {customer:"CountryNamess"},
        ]
      }
    ];
  }

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

Leveraging the power of the map function to cycle through two arrays

Right now in React, I am utilizing array.map(function(text,index){}) to loop through an array. But, how can I iterate through two arrays simultaneously using map? UPDATE var sentenceList = sentences.map(function(text,index){ return <ListGr ...

What is the best way to eliminate the blue outline around an image map?

On the landing page, I have a static background image and I've set up a clickable area using an image map. The issue is that when users click on the area, a blue border appears (see image below). I've tried several methods to remove this border b ...

Prevent the navigation bar text from being truncated

The below code snippet: <div data-role="navbar"> <ul> <li><a href="#page_1" data-transition="none">Heading 1</a></li> <li><a href="#page_2" class="ui-btn-active ui-state-persist">Heading 2</a& ...

Attempting to retrieve a URL from wunderground using Python version 3.3.2

I've been facing challenges for some time now while trying to update a piece of code from an older Python version. My aim is to do an API lookup from wunderground, but I keep running into errors in Python. Here's the specific error message: f = ...

Tips for changing the dimensions of the canvas?

I'm struggling to display a photo captured from the webcam. The sizes are not matching up, and I can't pinpoint where the size is defined in the code. https://i.stack.imgur.com/Is921.png The camera view is on the left, while the photo should be ...

"Error: The .cssText method in Javascript is not working properly

I have been encountering an issue where the .cssText is not updating the HTML element referred to as .unveil. I implemented an event that when the container for .unveil is clicked, the .unveil element should become visible. However, upon clicking the .unve ...

Storing data locally in PhoneGap using localStorage via AJAX calls is a common requirement for

Our mobile application is built with cordova [phonegap] and we are looking to implement offline saving of results into the cache memory. The results are fetched from a PHP server and displayed in a webview using ajax and javascript. I have tried using loc ...

What is the method for conducting an Ajax request?

Currently, I am deeply involved in a personal project to enhance my skills with Rails. The project involves developing a task management application that encompasses three primary states: todo, in progress, and done. After numerous days of trial and error, ...

Combining arrays of objects using JSON format in JavaScript

Here is an example of a JSON file: [ { "stores": [ { "name" : "My store", "location" : "NY" }, { "name" : "Other store", ...

JQuery's document.ready function triggers prematurely on dynamically loaded HTML content

When loading dynamic content, I use the following method: $('#my-div').load('my.html'); The code inside my.html looks like this: <html> <head> </head> <body> <script> $(fu ...

Guide to animating an HTML element with CSS

Recently, I've been pondering the process of animating an HTML element solely through CSS. Unfortunately, my knowledge on the subject is quite lacking... I attempted to utilize the animate keyword in pursuit of this goal ...

Is it possible to adjust the height of input fields in MUI Reactjs?

Having trouble adjusting the height of input textfields using in-line css. <FormControl sx={{ "& .MuiOutlinedInput-notchedOutline": { borderColor: "blue", }, "&.Mui-focused .MuiOutlinedInpu ...

Changing the InnerHTML of a tag in JavaScript using class and id attributes

When it comes to handling these links <div class="post_actions"> <a class="color-transition article_delete" href=""><i class="fa fa-pencil"></i></a> <a class="color-transition article_edit" href="#" id="1">< ...

Use the evernote findNotesMetadata function to efficiently retrieve all notes by implementing an offset and maxnotes parameter for looping through

According to the documentation provided by Evernote regarding findNotesMetadata, the maximum number of notes returned from the server in one response is 250. I am currently exploring how to handle multiple requests in order to retrieve the entire array if ...

When an input is disabled in "react-hook-form", it may return undefined

Within my React application, there exists a form containing various input fields. I have enclosed these fields using FormProvider imported from react-hook-form and utilized register within each field. import { useForm, FormProvider, useFormContext } from & ...

Is there a way to efficiently pull specific time-related data from XML API forecasts using PHP and present them in HTML tables?

Currently, I'm facing a bit of confusion on how to obtain a forecast for the upcoming 5 days of a specific city using OpenWeather's forecast api. The challenge lies in the fact that the forecasts are provided in 3-hour intervals, but I only requi ...

Tips for displaying HTML content using an array in Vue JS

Hi, I'm a beginner with Vue JS and I'm working on passing an HTML table using this array. I have a dropdown where I can select the option I want, but I'm struggling to figure out how to include HTML within it. Whenever I try, it ends up disp ...

Beginner Query: What is the method for retrieving this data in JavaScript?

I'm struggling with accessing a specific value in an Object in JavaScript for the first time. The JSON I'm working with is structured like this: { "payload":{ "params":{ "switch:0":{ &q ...

What is the process of exporting the app object in Express?

My application object is initialized in the app.js file: var app = express(); var reg = require('./routes/reg'); app.use('/reg',reg); ... ... module.exports = app; In reg.js, I use app.get(): var app = require("../app.js"); ... ... a ...

Does using the HTML doctype result in adding extra whitespace?

Could someone provide an explanation as to why setting a doctype of <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> and <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> results in different rendering of the following ...