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:

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:

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

Combining jqueryUI autocomplete and datalist for enhanced user input options

My search form in HTML has a single input field where users can enter three different things: area name, trek name, or other keywords. For areas not in a database, I have implemented a datalist field (HTML) connected to the input for autocompleting the a ...

How can I integrate material-ui with react-jsonschema-form?

Currently, I am working on a form utilizing react-jsonschema-form. However, I would like to further enhance the appearance of my application (including the form) by incorporating Material-UI. I am encountering difficulties integrating both frameworks toget ...

Issue: formGroup requires an input of type FormGroup. Please provide one; Error: Unable to access property 'controls' as it is undefined

In the process of building a login and registration form using Angular with .Net core, I encountered an error upon running the program. The error is showing up in the Browser Console tab. This is my userlog.component.ts file: import { Component, OnInit, O ...

Tips for entering Tamil characters in text boxes on a form field

Within my form, I have a set of text boxes. I am looking to input text in Tamil font for specific text boxes - around 5 out of the total 10 text boxes in the form. If you know how to enable Tamil font input for multiple text boxes (rather than just one as ...

Using JSON within HTML: A guide to sanitizing stringified objects

Is there a way to improve the readability of a string that looks like an object but is actually just a string? It currently does not look very nice and easy to read. Using JSON.parse doesn't work because not every element in the string meets the requi ...

Encountered an Angular 2 error: NullInjectorError - Http provider not found

I've encountered an issue while trying to access a JSON GitHub service, receiving the error message NullInjectorError: No provider for Http! Although I've attempted to add providers throughout the code, my efforts have been unsuccessful. I' ...

Encountered an issue with ionViewDidLoad: The property 'firstChild' cannot be read as it is null

While working on an Ionic 2 App with Angular2 and Typescript, I encountered an issue when trying to pass a JSON to map for markers. Here is the link to the gist containing the code snippet I am facing an error that reads: view-controller.js:231 MapPage i ...

Struggling to add a border to an HTML div element

I'm completely baffled as to why I can't seem to add a border around my div. Here is the link to my jsfiddle: http://jsfiddle.net/4HnKs/1/ It's possible that I've been staring at my computer screen for too long, but no matter how hard ...

Tips for implementing absolute import paths in a library project

In my workspace, I have a library with two projects: one for the library itself and another for a test application. ├── projects    ├── midi-app    └── midi-lib Within the workspace's tsconfig.json file, I set up paths for @a ...

Issues with PHP Form Email DeliveryIt seems that there is a

I currently have a ready-made form that is constructed using html, css, jquery, and ajax. It's basically copied and pasted onto my contact page for now. This is the code I include before the html tag on the contact.php page. <?php session_name(" ...

Save room for text that shows up on its own

I am currently dealing with a situation where text appears conditionally and when it does, it causes the rest of the page to be pushed down. Does anyone know the best way to reserve the space for this text even when it's not visible so that I can pre ...

Creating a unique and personalized dual-row navigation bar using Bootstrap

Currently, I am striving to achieve a "conflict free" two-row fixed-top navbar in Bootstrap 3. I am unsure if it necessitates two separate "navbars" according to the official Bootstrap definition. While I possess decent coding skills, my knowledge of the B ...

Ways to transfer arguments from a subclass component to its superclass

Currently in the process of upgrading from Angular 7 to Angular 12. I have multiple components that inherit from a shared base class, where constructor arguments are passed in. Main Component export abstract class PageBase implements OnDestroy{ const ...

Leveraging Next.js with TypeScript and babel-plugin-module-resolver for simplified import aliases

I am currently in the process of setting up a Next.js project with typescript. Despite following multiple guides, I have encountered an issue concerning import aliases. It's unclear whether this problem stems from my configuration or from Next.js its ...

Chrome on IOS: Experiencing screen freezing while scrolling

1) I'm working with Material UI in React JS. I have added a simple scrollable code, but when I reach the bottom of the screen/scroll, it freezes. 2) I also tried it with a simple HTML page and it worked correctly. <div style={{ ...

Can integer values be stored in localStorage similar to JavaScript objects and retrieved without requiring typecasting?

After setting an integer value to a localStorage item: localStorage.setItem('a', 1) and checking its data type: typeof(localStorage.a) "string" it shows as a string. I then typecast it to an int for my purposes: parseInt(localStorage.a) My ...

Trouble encountered with the implementation of setValue on placeholder

When I send the value for age, it is being treated as a date in the API that was built that way. However, when I use setValue to set the form value and submit the form, it also changes the placeholder text, which is not what I want. I would like the placeh ...

Events related to key press timing in HTML 5 canvas

Currently, I am developing a game similar to Stick Hero for Android using HTML5. I am working on the code that will capture the time of key press (specifically the right arrow key with ASCII 39) in JavaScript and expand a stick accordingly. <!doctype h ...

Ways to define css attributes for the "before" and "after" pseudo elements in the DOM

I'm looking to modify the color of the "border-left" property from its default red to a different color within the scope, such as blue. .hello:before { content:' '; display:inline-block; width: 22px; height: 25px; ...

How to link a CSS file from a JavaScript file

I have a form for users with fields for first name, last name, password, and confirm password. I've implemented validation to check if the password and confirm password fields match using JavaScript: $(document).ready(function() { $("#addUser").cl ...