The information that is visible in the console is failing to appear in the view

My issue revolves around retrieving data from Firestore. While the console displays the data correctly, my view ends up showing empty cards.

Consider the following HTML code:

 <ion-grid>
        <ion-row>
        <ion-col size="12" >
        <ion-card *ngFor ="let favorite of favoriteList">
          <img [src]="favorite?.image">
          <div class="card-title">{{favorite?.title}}</div>
        </ion-card>
        </ion-col>
      </ion-row>
      </ion-grid> 

Here's the TS code snippet:

 favoriteList: any;  
 public favoriteListRef: firebase.firestore.CollectionReference;

 this.favoriteService.getfavoriteList().then(favoriteListSnapshot => {
      this.favoriteList = [];
      favoriteListSnapshot.forEach(snap => {
        this.favoriteList.push({
          id: snap.id,
          image: snap.data().image,
          favorite: snap.data().favourite
        });
        console.log(snap.data().favourite)
        return false;
      });
    });
  }

The Favorite Service function is defined as:

async getfavoriteList(): Promise<firebase.firestore.QuerySnapshot> {
    const user: firebase.User = await this.authService.getUser();
    if (user) 
          {
    this.FavoriteListRef = firebase
      .firestore()
      .collection(`userFavorites`);
    return this.FavoriteListRef.where('uid', '==', user.uid).get();
              }
           } 
       }

I'm seeking guidance on where I'm going wrong in this process. Any insights would be greatly appreciated.

Answer №1

The Array in your reply contains images that are not visible due to the incorrect "src" attribute value in the <img> tag.

To display the image, you should use the first URL in the image array as the src attribute.

<img [src]="favorite?.image[0]">

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

Storing service data within Angular2 components

As I work on creating a login service called AuthService for my Angular 2 application, I'm facing unexpected challenges. My main goal is to have a single user object that remains consistent throughout the entire application after a user logs in. This ...

Error with Firebase authentication on a Next.js project using TypeScript

I recently started a personal project using Next.js, Typescript, and Firebase for authentication and database management. While working on a sign-in page with Google integration, I encountered an error labeled as auth/argument-error. According to the Fireb ...

I am encountering an issue where body-parser is not functioning properly with typescript. Whenever I make a request, the request.body is returning as undefined

Below is the code snippet for my Express application using TypeScript version 3.7.4: import bodyParser from "body-parser"; import config from "config"; import cookieParser from "cookie-parser"; import express from "express"; import mongoose from "mongoose ...

Is there a way to track all Angular form controls that have switched between being enabled and disabled?

Summary: When a FormGroup contains a nested FormControl that changes from disabled to enabled or vice versa, the FormGroup is not marked as dirty. Details: How can you identify all form controls within a FormGroup that have switched between being enabled ...

utilize the entire space designated for the <router-outlet> component

I am working with 3 components: <menu (setAnimal)='setAnimal($event)' ></menu> //PrincipalComponent <router-outlet (activate)='onActivate($event)'></router-outlet> <footer></footer> The red border ...

Position the center of an Angular Material icon in the center

Seeking help to perfectly center an Angular Material icon inside a rectangular shape. Take a look at the image provided for reference. https://i.sstatic.net/oFf7Q.png The current positioning appears centered, but upon closer inspection, it seems slightly ...

Although Ionic 2 has been successfully installed, it appears to be missing from the output of the command 'ionic info'

After installing Ionic 2 and Cordova on my Windows system, I encountered an issue where it was not showing up when running 'ionic info'. This prevented me from being able to run my Ionic project. Upon running ionic info, the following output was ...

Creating dynamic tags based on values is a straightforward process that involves identifying key variables

Looking to create a template that can dynamically define native HTML tags based on a variable value. I attempted using a custom directive to swap out the initially defined tag with the desired new one, similar to what is discussed here. While this approac ...

Guide to implementing validation in an angular 2 dropdown using the Model-driven Approach

When the user clicks the submit button, the dropdown validation does not occur. I want the form to be validated if the user does not select any value, and in that case, the form state should be invalid. In my scenario, I have disabled the submit button whe ...

Issue with Angular 6 where data is not binding to the UI on initialization

I am struggling with binding dynamic data to the UI and Data tables on my website. Despite trying various methods, I have not been able to achieve success. Currently, I am using the smart admin latest theme for development. When I make a call to the API, ...

Steps for incorporating the pull-to-refresh feature in CDK virtual scrolled Angular application

My current setup involves using CDK virtual scroll in the DOM, however I have encountered a glitch when scrolling quickly. To address this issue, I am considering implementing the Pull to Refresh method. Can anyone provide guidance on how to implement Pu ...

Utilize AWS CDK Step Function Task to incorporate a list of objects within the DynamoPutItem operation

I am currently facing a challenge with using the DynamoPutItem task to insert an entry that includes a list of objects as one of its attributes. I have searched online for examples of this but have not found any, leading me to question if it is even possib ...

To subscribe to the display of [Object Object], you cannot use an *ngIf statement without being inside an *ngFor loop

In my angular Quiz project, I have a functionality where every user can create quizzes. I want to display all the quizzes that a logged-in user has completed. Here is how I attempted to achieve this: // Retrieving user ID and category ID inside Re ...

Having trouble importing or resolving files with ts-loader or css-loader?

Struggling to incorporate css modules by utilizing style-loader and css-loader in my project. I am facing difficulties understanding the root cause, unsure if it's ts-loader or css-loader to blame. webpack.config.js const path = require('path&a ...

The interface 'children: string' does not share any properties with the type 'IntrinsicAttributes'.ts(2559)

When I export the component, the value from the input email does not appear as a VALUE property. How can I collect the text written in this exported component in my code? NOTE: I am working on developing a design system using STORYBOOK. export const Login ...

How to set up Apache to configure direct access to a specific route in Angular 2 routing?

I built a small Angular2 test application that includes routing functionality. Everything runs smoothly when the user starts from the home page and navigates to sub-pages. If the user tries to directly access a sub-page, they will encounter a 404 error u ...

An issue has occurred: [ERR_REQUIRE_ESM] You must utilize the import statement in order to load an

These are the snippets of code I'm working with: index.ts import { MikroORM } from "@mikro-orm/core" import { __prod__ } from "./constants"; import { Post } from "./entities/Post"; import microConfig from "./mikro-o ...

Unexpected identifier error: Typescript interface name syntax is incorrect

I am currently learning Typescript and still navigating my way through it. I have extensively searched for a solution to the issue I am facing, but couldn't find one, hence I am seeking help here. The problem lies in a SyntaxError at the interface nam ...

Update Angular2 application's routes dynamically

Currently, I am developing an application that involves dynamically loading modules based on JSON data. I am looking to modify the app's routing depending on the user's permission to view certain modules. Can you provide guidance on how to accomp ...

I'm having trouble establishing a connection with the Appwrite platform

Encountered an issue while trying to connect to appwrite. The specific error message is: Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL at Account.<anonymous> (appwrite.js?v=d683b3eb:932:19) at Generator.nex ...