Angular's table data display feature is unfortunately lacking

Below is a simple HTML code snippet:

<div class="dialogs">
  <div id="wrapper" >
    <p>{{createTestingConstant()}}</p>
        <ng-container *ngFor="let one of contacts">
          <p>{{one.NickName | json }}</p>
        </ng-container>
  </div>
</div>

In this code, I am trying to display the output of a function and each nickname from the data table.

Here is the typescript file:


@Component({
  selector: 'app-get-chat',
  templateUrl: './get-chat.component.html',
  styleUrls: ['./get-chat.component.scss'],
})
export class GetChatComponent implements OnInit {
  contacts: Contact[];
  constructor(private contactService: ContactService) {}

  ngOnInit(): void {
    this.contactService.getAll().subscribe((_) => {
      this.contacts = _;
    });
  }

The function being used:

  createTestingConstant(): bigInt.BigInteger {
    return bigInt(1);
  }
}

Contact service:


@Injectable({
  providedIn: 'root',
})
export class ContactService {
  private url = environment.apiUrl + '/contact';

  constructor(private http: HttpClient) {}

  public getAll(): Observable<Contact[]> {
    return this.http.get<Contact[]>(this.url);
  }


  public create(request: CreateContactRequest): Observable<void> {
    return this.http.post<void>(this.url, request);
  }
}

The resulting view:

https://i.sstatic.net/nc01l.png

However, simplifying the code doesn't yield the expected result:

<div class="dialogs">
  <div id="wrapper" >
    <p>{{createTestingConstant()}}</p>
        <ng-container *ngFor="let one of contacts">
          <p>{{one | json }}</p>
        </ng-container>
  </div>
</div>

The actual outcome can be seen here:

https://i.sstatic.net/Swb12.png

Question: Why am I unable to retrieve the `NickName` attribute individually, and how should I approach displaying only that specific attribute?

Thank you for any assistance.

P.S.: Additional Information about the Contact interface

import * as bigInt from "big-integer";

export interface Contact {
    ContactID: bigInt.BigInteger;
    ContactLogin: string;
    NickName: string;
    Pass: string;
    ProfilePhotoPath: string;
    PhoneNumber: string;
  }

Answer №1

There seems to be a typo in the nickName field

<div class="dialogs">
  <div id="wrapper" >
    <p>{{createTestingConstant()}}</p>
        <ng-container *ngFor="let one of contacts">
          <p>{{one.nickName | json }}</p>
        </ng-container>
  </div>
</div>

Answer №2

After some revisions, I have updated the Contact interface and it appears to be working well:

export interface Contact {
    contactID: bigInt.BigInteger;
    contactLogin: string;
    nickName: string;
    pass: string;
    profilePhotoPath: string;
    phoneNumber: string;
  }

I have changed uppercase letters to lowercase, but incorporating C# convention is still a mystery to me.

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 steps can I take to stop my browser from displaying the "waiting for MyHostName" message while performing an ajax Post/Get operation?

Whenever I access a website using Chrome, a message appears in the status bar saying "Waiting for MyHost name" along with an Ajax Loader circle in the browser tab. Here is a javascript function that I am working with: function listen_backend_client_reques ...

Troubleshooting jQuery's issue with dynamically adding input fields

I came across a tutorial (which I tweaked slightly) on this website: code In JSFiddle, everything works perfectly fine with the code. However, when I implemented it on my actual page, it's not functioning as expected. I've been trying to trouble ...

Chromium browser experiencing issues with the functionality of Dropdown component

My issue involves a basic pie chart with a dropdown menu (created with the <select> tag) that allows users to change the data displayed on the chart. I have implemented this in Angular 6 and it works perfectly fine in Firefox. However, when I tested ...

Step-by-step guide to creating a clickable div

Having an issue with around 200 clickable buttons on my website, all designed the same: <div> <asp:hyperlink> //or LinkButton </div> The background-style of the button is within the Div and the text of the button is in Hyperlink / LinkB ...

Can someone share tips on creating a stylish vertical-loading progress bar with a circular design?

Currently, I am working on developing a unique progress bar that resembles a glass orb filling up with liquid. However, due to its rounded shape, the traditional approach of adjusting the height does not produce the desired result (as illustrated in this f ...

I am wondering how to use the value assigned to a variable's textContent as an argument for player input in my JavaScript code

i am currently developing a JavaScript project to create a user interface for my rock, paper, scissors game. Currently, the game only runs in the console and prompts the player for input. So far, I have implemented three buttons (one each for rock, paper, ...

Is there a way to retrieve the ID from a span and convert it into a string format?

let wordSpan = '<span class="we w_o_r_d_s" id="we" contenteditable="false">we</span>' console.log(wordSpan.id); console.log(wordSpan.attr('id')); console.log(wordSpan.getAttribute('id')); let newDiv = document.c ...

What is the best way to include a class in the <td> element of a dynamic table?

My goal is to sum up the values in a specific column of a dynamic table by attaching an id property to each row. I am specifically focused on assigning an id to each <td> in every row of the table. UPDATE: Although I have all 4 keys in the <td> ...

Using jQuery to slide elements across the page

I've been attempting to incorporate a sliding effect into my website, but I'm running into an issue where the sliding only occurs on the first click and I can't figure out why. Here is the code snippet I've been using: Html : $("#go ...

Setting up the foundations in Angular 4

Using WebStorm 2017.1.4, I am working on creating the front end of my J2EE application. Within this project, I have two components: "about" and "contacts". In the latter component, my goal is to include all contacts from a MySQL database. However, I encoun ...

Leverage JavaScript Object Properties within Angular 5 Components

Here's a question I have on using ngx-charts in Angular 5. I am experimenting with ngx-charts to create a chart within my Angular 5 project. The code snippet for my component is shown below: import { Component, OnInit } from '@angular/core&ap ...

Allow users to modify multiple rows in a customizable table with Flask

I am currently working on a web application that utilizes Flask/Python as the back-end with SQLite, and HTML/CSS/JS (Bootstrap) for the front-end. In one specific section of the application, users should be able to edit multiple fields simultaneously in a ...

Converting JSON objects into TypeScript classes: A step-by-step guide

My challenge lies in converting Django responses into Angular's User array. This conversion is necessary due to variations in variable names (first_name vs firstName) and implementing specific logic within the Angular User constructor. In simple term ...

Adding JavaScript files to a project in Ionic2 with Angular2 integration

I'm looking to incorporate jQuery into my Ionic2 app, which requires loading several JavaScript files: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/j ...

Issue with Npm installation command on Windows 7 64-bit system

When I run the command "npm install" from my project folder, I encounter the following errors: Error: Windows_NT 6.1.7601 Node version: v6.10.3 NPM version: v3.10.10 Code: ENOTFOUND Network error: getaddrinfo ENOTFOUND registry.npmjs.org regist ...

Discover the step-by-step guide for inserting personalized HTML into the current widget screen on Odoo 12 with

For the past 3 days, I've been stuck trying to figure out how to print order items. My goal is to have a custom HTML code added to a div with the class 'order-print' when the Order button is clicked. I am using odoo 12 and facing issues wit ...

Ways to enable automatic scrolling of a page as the content expands (Utilizing collapsible elements)

For a recent project I've been working on, I decided to include 4 collapsible text boxes. However, I encountered an issue where opening content1 would expand and push down content2-4, requiring the user to manually scroll to view the remaining collaps ...

Getting just the outer edges of intricate BufferGeometry in Three.js

Currently, I am immersed in a project that involves zone creation and collision detection using Three.js. The primary objective is for my application to effectively manage collisions and produce a BufferGeometry as the final output. My aim is to visually r ...

Transitioning from Tailored CSS to Bootstrap

While I am experienced in HTML and CSS, I am new to working with Bootstrap. Here is a code snippet that works well but has a lot of custom CSS. Below you can see my HTML and CSS code. .container { padding: 150px; display: flex; align-items: center ...

Having trouble with PHPmailer resulting in a 504 gateway timeout error

I keep receiving a 504 gateway timeout error from my server when using phpmyadmin to individually send emails to a list of approximately 1200 users. It is crucial for me that the emails are sent out one by one, as I want to avoid exposing any email addres ...