Issue with Angular ngFor within a particular dialog window?

(respPIN and internalNotes are both of type InternalNotes[])

When the code in encounter.component.ts is set like this:

this.ps.GetInternalNotes(resp.PersonID.toString()).subscribe(respPIN => {
    this.internalNotes = respPIN;
});

An ERROR occurs: Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

To resolve this issue, I made the following change:

this.ps.GetInternalNotes(resp.PersonID.toString()).subscribe(respPIN => {
  for (let index = 0; index < respPIN.length; index++) { 
            this.internalNotes.push(respPIN[index]);
        }
});
    

After inspecting the data using DevTools debugger, it seems fine (an array of JSON objects with key-value pairs). However, the data does not display in the table of the dialog.

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

This is how the data is sent from that component to the dialog:

this.dialog.open(DialogInternalNotesThreeComponent, {
          data: {
                data: this.internalNotes
            }
      });

In dialog-internal-notes-three.component.ts:

this.internalNotes = this.data;   

In dialog-internal-notes-three.component.html:

<table>        
    <tbody>
        <tr *ngFor="let note of internalNotes">
            <td>{{note.CreateDate}}</td>
            <td>{{note.CreatedByText}}</td>
            <td>{{note.Note}}</td>
        </tr>            
    </tbody>
</table>

What might be causing this issue?

Answer №1

By adding a reference to the data within the ngFor loop, the issue was successfully resolved:

<tr *ngFor="let note of internalNotes.data">

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

Customized interfaces utilizing generic components

Here is my simplified question. interface Identity{ name: string; } Next, we have a generic interface. interface State<T extends Identity>{ [T.name] : StateContainer<T> } Unfortunately, this approach fails and the following error is ...

What is the most effective method for structuring JSON data that is utilized by a single-page application (SPA)?

A colleague and I are collaborating on a single page application (built in React, but the framework used isn't crucial; the same query applies to Angular as well). We have a database with 2 interconnected tables: Feature Car Both tables are linked ...

Using the "$and" condition in MongoDB is a useful feature for querying documents based on multiple

I attempted to retrieve the id and name of students who did not pass the English exam in MongoDB. Those who failed have a grade of "N", while those who passed have a grade of "P". I am uncertain if I used the "and" statement correctly. db.enrolment.find ...

Utilize generic types as object properties in TypeScript

Is there a way to achieve something similar in TypeScript like the following: export type CoordinateSelector = <T>(d: Coordinate) => d[T]; export interface LinkVerticalLineProps { x: CoordinateSelector<'x'>; y: CoordinateSele ...

Is it possible to customize the appearance of a toast notification using Toastr beyond the default settings? If so, what options are available for creating

Working with Angular 9 and ngx-toastr has presented me with an interesting challenge. I am tasked with creating custom toast styles that differ significantly from the default ones provided by toastr. Each toast in the set will have unique border colors, f ...

Guide to setting headers to application/json in Angular 2

I've been attempting to send an HTTP post request in Angular 2, but I'm facing difficulties setting the headers to content type application JSON. This is my current code: login(url, postdata) { var headers = new Headers({'Content-Type&a ...

Establish a connection between MongoDB and the built-in API in Next.js

I've been working on integrating a MongoDB database with the Next.js built-in API by using the code snippet below, which I found online. /api/blogs/[slug].ts import type { NextApiRequest, NextApiResponse } from 'next' import { connectToData ...

Showcase pictures within an angular smart table

Is it possible to display images in a column within an ng smart table? We have several columns consisting mostly of data, with one column dedicated to displaying images. Following the ng smart table concept, I attempted to implement the code below which cu ...

Tips for storing a searchable and queryable JSON file in Postgres?

How can I effectively model a person's profile received in JSON so that every value is searchable? Additionally, how can I make it queryable for specific criteria such as finding all persons who like Tarantino movies? While a relational model with one ...

The current context for type 'this' cannot be assigned to the method's 'this' of type '...'

Currently, I am in the process of defining type definitions (.d.ts) for a JavaScript library. In this specific library, one of the methods accepts an object of functions as input, internally utilizes Function.prototype.bind on each function, and then expos ...

Querying JSON Data in an Ajax Request: A Simple Guide

I have a data file in json format that looks like this: {"markers":[ { "latitude":11.58655, "longitude":122.755402, "type":"A"}, { "latitude":11.00698, "longitude":124.612801, "type":"B"}, { "latitude":10.30723, "longitude":123.898399, "type": ...

Type verification not functioning properly in a standalone TypeScript function

I am trying to validate the type of a parameter in a separate function, but I keep getting this error: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable ...

Error message: "Incompatible types in Typescript"

As I delve into learning TypeScript, I have encountered two errors that are causing me some trouble. We have a problem with the following lines of code: Type 'string | null | undefined' is not assignable to type 'string | RegExp | QuerySelec ...

Guide on altering an element's attribute in Angular 2

Is there a way in Angular to dynamically change the attribute of an HTML element? I want to create a button that can toggle the type attribute of an input from password to text. Initially, I thought about implementing it like this: Template: <input na ...

Issue with Angular2 - namespace webdriver not detected during npm installation

Upon restarting my Angular2 project, I ran the npm install command and encountered this error message: node_modules/protractor/built/browser.d.ts(258,37): error TS2503: Cannot find namespace 'webdriver' Does anyone have insight into the origin ...

Remove outdated choices from subcategory menu upon JSON data retrieval

By using the onchange event in the parent dropdown (first dropdown), I am populating the child dropdown (second dropdown). Subsequently, upon selecting an option from the child dropdown, I automatically fill in three text boxes. However, I am facing an iss ...

Error in Angular ESLint: The key parameter is mandatory

I'm attempting to download a file using the Angular code below, but I consistently receive an error stating Parameter "key" required const headerValues = new HttpHeaders({ 'Content-Type': contentType!, 'Accept': contentTy ...

Retrieve a JSON object from a URL by utilizing the Facebook Graph API within a Ruby on Rails environment

Does anyone know how I can fetch the JSON object from a URL in my Ruby on Rails code? url = "https://graph.facebook.com/me/friends?access_token=XXX" I've been struggling to find a comprehensive tutorial for using JSON with Ruby on Rails. Any help wo ...

What is the reason behind TypeScript not stating "When comparing a string to a null value, the condition will always return 'false'?"

When comparing a string to a number, an error and warning are generated. But why is there no warning when comparing a string to null/undefined? In this case, the type 'smth' is still narrowed to never without any warning displayed. The strictNul ...

Is it possible for Angular components to retrieve information on the current route and parameters?

I am struggling to understand why it's so difficult... why we are not supposed to care about the route from outside the routed component.... HOWEVER: I am attempting to develop a service so that my header (and any other component) can have access to ...