Triggering a CSS class change in Angular based on Firestore events

I want to update a CSS class when new data is received from Firestore. I attempted the following code:

this.afs.collection('orders').doc(this.data.id).valueChanges().subscribe(dataset => {
  console.log(dataset.state);
  this.state = dataset.state;
  this.takeAway = dataset.takeaway;
});

Here is the corresponding HTML:

<div class="progress dark">
<div class="right">
  <div [ngClass]="{'current': this.state === 'submitted'}">Submitted</div>
  <div [ngClass]="{'current': this.state === 'cooking'}">Cooking</div>
  <div *ngIf="!takeAway" [ngClass]="{'current': this.state === 'delivery'}">Delivery</div>
  <div *ngIf="takeAway" [ngClass]="{'current': this.state === 'ready'}">Ready for Pickup</div>
  <div class="done" [ngClass]="{'current': this.state === 'done'}">Order Received</div>
</div>

The issue occurs when I first load my component, everything works fine. However, when the data has changed, nothing happens. I am definitely receiving the updated data, so the problem lies in how to bind the dynamic classes.

Answer №1

Through extensive research, I successfully resolved the issue at hand. It was discovered that Ionic had omitted adding a crucial dependency to my Podfile. Below is the updated podfile with all necessary dependencies and imports:

platform :ios, '11.0'
use_frameworks!
install! 'cocoapods', :disable_input_output_paths => true

def capacitor_pods
  # Automatic Capacitor Pod dependencies, do not delete
   pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
   pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
   pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
   pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'
  # Do not delete
 end

 target 'App' do
 capacitor_pods
 # Add your Pods here

  end

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

Encountering issue with Angular HTTP POST resulting in error 415 when calling .NET Core

Hello, I'm in need of assistance with posting to a .NET Core Web API as I am still new to Angular. I'm attempting to make a POST request at https://localhost:44394/api/SyUsers, but I keep receiving a 415 error. I have tried setting the headers a ...

"Optimizing Angular2 with Tree Shaking using Webpack2 and ng

In my angular2 application, I am currently utilizing https://github.com/ng-bootstrap/ng-bootstrap with webpack2 to compile all ts files. At the moment, I am only using the Modal Component from NgbModule. However, even in the minified file, I can still see ...

Design a custom scrolling navigation bar for enhanced user experience

Struggling with web design as I develop a site in ASP.NET. I have a database full of courses, each with numerous modules. The challenge is creating a navigation bar that dynamically adjusts to accommodate the varying number of modules per course without o ...

Utilizing movingMarker from leaflet-moving-marker in Angular: A Step-by-Step Guide

I am currently working on incorporating the leaflet-moving-marker plugin but encountering some errors in the process. import {movingMarker} from 'leaflet-moving-marker' var myMovingMarker = L.movingMarker([[48.8567, 2.3508],[50.45, 30.523 ...

Disabling the ability to edit the rightmost portion of an input number field

I am looking for something similar to this: https://i.stack.imgur.com/ZMoNf.jpg In this case, the % sign will be shown in the input field by default and cannot be changed or removed. The user is only able to modify the number to the left of the % sign. P ...

Tips for incorporating an image into the background of a mobile device

My attempt to set an image as a background was successful on desktop, but unfortunately, it doesn't work on my phone. I have specified 'cover' as the background-size, expecting it to cover all the space on mobile as well. Here is the code s ...

Switching row visibility based on condition failure is malfunctioning

Having trouble toggling a specific table row based on a condition that is not working as expected. If the status is 'none', I want to open a form in a popup, but if the status is 'done', the popup should not open. <ng-container *ngF ...

unexpected issue with npm package installation

I am currently exploring NPM and angular2, and attempting to create my own NPM package for local installation. I was able to successfully create the package (test-package-0.0.1.tgz) which includes: ├── .npmignore ├── README.md ├── LICENS ...

The scrollspy feature in Bootstrap 5 fails to highlight the correct sections

Despite following the steps, my scrollspy is not highlighting. What could be the issue? I have replicated the HTML and CSS codes directly from getbootstrap.com. <!DOCTYPE html> <html lang="en"> <head> <meta charset="u ...

The navigation bar menu fails to collapse when the menu icon is clicked

There are two issues with my bootstrap implementation that I am facing: After clicking on the hamburger icon in the mobile view to open the menu, it does not close when clicked again. It remains open at all times. When hovering over the menu links un ...

In what ways can the use of !important cause issues for website users?

When it comes to accessibility, is using !important not the best practice? In what ways can the use of !important cause problems for site users? ...

What could be causing the hover effect to malfunction in this code snippet?

I have been working on creating a hover effect for a list of items where an underline emerges from the center. While I have done something similar in the past, there seems to be an issue preventing it from working properly this time. I have included the HT ...

Personalize the layout for vertical table headings and table information

I need help with a table that has vertical headers. I want to remove the extra space within the table header and data cells. Here is the code for my table: <table> <tr> <th class="field">Item ID Number:</th> < ...

The HTML Email Template fails to incorporate certain CSS styles

When attempting to create an HTML Email template that includes a button with a link and has a maximum width with consistent margins on both sides, I encountered some issues. While certain parts of the CSS were applied correctly, others were not displaying ...

how to insert a new element into an array in Angular

Attempting to utilize a variable defined in my .ts file to populate an array for handsontable, but unable to retrieve the value. The variable does have a value as confirmed by console logging. console.log("t1 title " ,this.t1Title); Addition of the stri ...

Customize Individual Rows in a React DataGrid

I am exploring the world of Material UI React data grid for the first time, and I am looking to add a unique background color to only the initial three rows. Each row should have a different color scheme that remains static, without any interactions trigge ...

Can a Material UI Select element be made unresponsive to hover effects?

When a user hovers over an element, I want to achieve the following functionality: document.getElementById("dropdownCategory").disabled = true; <Tooltip arrow placement="right" title={props.description} > <FormControl id="dro ...

Issue with ngmodel causing placeholder in Angular 2 md-input to not move up

While working with Angular Material to style an input field, I noticed that the placeholder does not move up when there is a value in the input. This behavior occurs only when using ngModel to bind the input. Interestingly, clicking on the input causes the ...

Retrieve the md-sidenav-layout element within a TypeScript file component

Using md-sidenav in my application has been quite useful. Assigning an object to md-sidenav involves the following syntax: <md-sidenav #start With this syntax, "start" will hold all variables and methods of md-sidenav, allowing for operations such ...

Pseudo Elements: The Transformative Power of Before and After

JS Fiddle Looking for some CSS help: <div id="strip"></div> This is my setup: width: 100%; height: 130px; background: grey; I'm trying to add a pseudo-element after the strip, positioned at the bottom. #strip:after { content: "" ...