Angular 2 App Encountering Async Pipe Issue with Observable

I have successfully implemented pagination in my Angular 2 application, but I am encountering an issue related to the async pipe:

Invalid argument '' for pipe 'AsyncPipe'

Upon researching this error, it seems to be linked to the async pipe expecting an observable. The confusing part is that I am indeed using an observable, so I am unsure of what is causing the problem.

Let's take a look at the relevant view code:

<tr *ngFor="let record of records | async | paginate: { id: 'stream', itemsPerPage: 15, currentPage: page, totalItems: total }">

This component relies on an Input() from another component, demonstrated as follows:

@Input() records = [];

Here's the "records" data from the other component, which is being subscribed to OnInit:

ngOnInit() {
   this.streamService.getBySection('section1')
        .subscribe(resRecordsData => this.records = resRecordsData,
        responseRecordsError => this.errorMsg = responseRecordsError);
}

What could be causing this issue? Do I need to explicitly specify the type as observable somewhere?

Answer №1

The async pipe requires an observable instead of the resolved data.

ngOnInit() {
   this.items = this.dataService.fetchItems('category1');
}

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 correct way to customize colors for specific components in Material-ui?

Struggling with theming in Material-UI, particularly when it comes to customizing element colors. Some elements default to 'theme.palette.main.dark' and I want to override this behavior. For example, the TextField and SpeedDial components automa ...

Struggling with establishing connection logic between two database tables using Prisma and JavaScript

I'm facing a perplexing logic problem that is eluding my understanding. Within the context of using next-connect, I have a function designed to update an entry in the database: .put(async (req, res) => { const data = req.body; const { dob ...

Is it necessary for me to develop an Angular library in order to release a basic TypeScript class that makes use of Angular components?

In one of my Angular projects, I have a Typescript class called APIResponse that I want to convert into an NPM package for use in other projects. This class is not specific to Angular like a Service or Component. After doing some research on creating non-A ...

CSS tooltip within the document styling

Previously, I utilized the following code: I am seeking guidance on how to position the tooltip inline (to the right) with the parent div instead of above. Thank you for reviewing For a more user-friendly version, refer to this jsFiddle link HTML: < ...

What is causing the most recent iPhones to have issues with my Javascript code?

After analyzing my webserver logs, it appears that an iOS 14 device is categorizing one of my Javascript files as "injected". This file seems to be operating in a separate environment or namespace. As a result, any AJAX attempts made by the script fail bec ...

Retrieving live comments from YouTube streams for a customized React application

Currently working on developing a React Webapp to organize and showcase superchats during a live stream. My initial attempt involved utilizing the YouTube LiveChat API, but I hit a roadblock as it requires authentication from the live stream owner, which ...

The form validation feature in Element UI is having issues when used with the Vue 2 Composition API

I am currently developing a form that utilizes element UI's form validation within the vue 2 composition API environment. This form includes a table nested inside, making its structure somewhat complex. ... <div> <el-form ref=" ...

Switching up the colors of toggle arrow icons using jQuery

https://i.sstatic.net/Id0XP.png I am currently working on sorting a table and I want to use arrows to indicate which column is being sorted. I have the functionality to sort with arrows in place, but I would like to customize the color of the arrow in the ...

Displaying a JSON object in a component's state through appending

I am currently working with a function that takes the state of an object as input and performs various operations on it. After these operations, I need to update the state accordingly and display it in JSON format. Here is the initial state: state= { ...

The type definition file for '@types' is not present in Ionic's code base

After updating my Ionic 6 project to use Angular 3, everything works perfectly in debug mode. However, when I attempt to compile for production using 'ionic build --prod' or 'ionic cordova build android --prod', I encounter the followin ...

Is there a way to prevent pop-up windows from appearing when I click the arrow?

Is there a way to display a pop-up window when the green arrow is clicked and then hide it when the arrow is clicked again? I tried using the code below but the pop-up window disappears suddenly. How can I fix this issue using JavaScript only, without jQue ...

Is it possible to render a nested object using res.render()?

Is it possible to access a variable in client-side javascript using Jade that is passed from the server (Node)? To achieve this, I created a nested object: var clientData = {clientData:{ title: 'Title', body: "body", appadress: & ...

Displayed unfamiliar Obj characters on Google Chrome

Hey there, I'm new to Vue JS and Vuetify and could really use some help! I've been trying to display some HTML content from my data using v-html in Vue JS, but for some reason, strange OBJ symbols keep showing up. Here is a screenshot of what I ...

Is there a way to utilize the reset() function within an input form?

Is there a way to automatically reset the textbox when submitting a value? Below is my code: <!DOCTYPE html> <html> <body> <ul id="myList"> </ul> <input type="text" id="myText" value="&q ...

Show the text from the chosen option using jQuery with a button

Hey everyone, I have a question regarding a coding issue I'm facing. In this problem, I am unable to display the text from the selected option when I click the order button. The desired result is to show the selected option that I choose and display i ...

The onclick functionality is not functioning properly within email communications

My JavaScript code contains an AJAX call within Datatables, and this snippet of code is causing an issue: { "data": null, "width": "10%", "render": function(data){ icon2 = '<center><button type="button" class="btn btn-info ...

Retrieve form data from Vuex state to make edits

I recently completed a tutorial on Vue to enhance my skills, and I'm now facing an issue while trying to make some changes. The tutorial I followed can be found here. Specifically, I have a "settings" page where users can edit their profile details. ...

Is the radio functionality and dropdown menu experiencing technical difficulties?

I'm having issues with my code, specifically in the JS function when I try to retrieve values from radio buttons and dropdown menus. Can someone help me figure out what's going wrong? CSS: #mytable { width:400px; border: 1pt solid blac ...

Send a request from my own local client without encountering any Cross-Origin Resource Sharing (C

I am attempting to send a request from my locally hosted Node.js/Express.js client to a third-party API that I have deployed on the cloud. Strangely, I keep running into a CORS error whenever I make the request. The interesting part is that the request wor ...

Observable not triggering Subject.next() as expected

service.ts constructor() { this.cartUpdate = new BehaviorSubject<Array<AppCartItem>>([]); // this.cartUpdate.subscribe((items) => { // #### 1 // console.log('Service Items : ', items); // }); } add(item) : Obser ...