I am unable to show a variable on the screen

Column Tariff 1: The variable FRAIS_ETRANGERS is associated with CODE:"NEK01". This variable is displayed in the template.

Column Tariff 2: The variable FRAIS_ETRANGERS is linked to CODE:"NEK03". However, I am facing difficulties displaying this variable in the template.

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

I'm unsure why I'm unable to display Tariff 2? Here is the code snippet:

<ng-container *ngFor="let plnPlcInfo of tarificationTitre">
        <ng-container *ngFor="let svmInfo of plnPlcInfo.PLN_SVM">
            <tr class="text-center">
                <td>
                    <ng-container *ngIf="svmInfo.PLN[0].CODE === 'NEK01'">
                        {{ svmInfo.PLN[0].PLAGE[0].FRAIS_ETRANGERS }} %
                    </ng-container>
                </td>
                <td>
                    <ng-container *ngIf="svmInfo.PLN[0].CODE === 'NEK03'">
                        {{ svmInfo.PLN[0].PLAGE[0].FRAIS_ETRANGERS }}
                    </ng-container>
                </td>

                <td scope="col">{{ svmInfo.SVM }}</td>
            </tr>
        </ng-container>
    </ng-container>
    

The related service details:

export class TodoService {

       PLN_PLC = [
          {
            PLACECODE: 26,
            PLACELABEL: "Fundsettle",
            PLN_SVM: [
              {
                SVM: 16111801,
                ISIN: "LU0100749679",
                LABEL: "NEKR FD LIFESTYLE DYNAMICC",
                PLN: [
                   {
                      CODE:"NEK01",
                      PLAN:8,
                      CANAL:"*",
                      AV:"A",
                      LIB:"Fonds Amenkor 8",
                      DATEV_EFFECTIVE:"0001-01-01",
                      PLAGE:[
                         {
                            BORNE:9999999999999.99,
                            FRAIS_BORDEREAU:0.00,
                            FRAIS_RETRAIT:0.00,
                            TYPE_COURTAGE:1,
                            COURTAGE:0.00,
                            MIN_COURTAGE:0.00,
                            TYPE_FRAIS_ETR:1,
                            FRAIS_ETRANGERS:2.00,
                            MIN_FRAIS_ETR:0.00
                         },
                         ...
                     
                   },
                   ...
               ]
             }
          ]
        }
      ];
      
      constructor() {}
      
    }
    

I have created a demo using Stackblitz.

Thank you for your assistance.

Answer №1

Upon examining your data structure, it becomes apparent that svmInfo.PLN[0].CODE consistently equals NEK01, rendering the condition

*ngIf="svmInfo.PLN[0].CODE === 'NEK03'"
perpetually false.

You might also consider iterating through the index for PLN as the values are as follows:

svmInfo.PLN[0].CODE = "NEK01"
svmInfo.PLN[1].CODE = "NEK01"
svmInfo.PLN[2].CODE = "NEK03"
svmInfo.PLN[3].CODE = "NEK03"

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

Creating API data by subscribing to the global Angular 5

What is the best way to ensure that the author variable is accessible in all methods? I have an array called author[] which is assigned data from an API in the subscribe method. Although I can bind this property to an HTML component, it appears as an empt ...

What is the rationale behind TypeScript's decision to implement two checks for its optional chaining and null-coalescing operators during compilation?

What is the reason behind the way the TypeScript compiler translates its optional chaining and null-coalescing operators, found here, from: // x?.y x === null || x === void 0 ? void 0 : x.y; // x ?? y x !== null && x !== void 0 ? x : y as opposed ...

The dimensions of my Angular app have begun to unexpectedly expand

Currently in the process of developing an Angular application, I've encountered a frustrating issue. Each time I refresh the app using ng serve, the loading time seems to increase gradually. It can now take up to 10 seconds for changes to reflect in t ...

Encountering an Issue while Attempting to Deploy Angular 6 on Her

I recently pushed my Angular 6 application to Heroku. Although the deployment was successful, the page is not loading properly. An error message on the page reads: An error occurred in the application and your page could not be served. If you are the ap ...

Securing your Angular application with user authentication and route guarding ensures

In the process of developing an Angular single-page application (SPA) front-end that interacts with a GraphQL endpoint, I encountered a challenge. Upon user login, I store the token in local storage and update the authentication state in my AuthService com ...

Exploring ways to incorporate the context value into my component's functionality

Hi, I'm new to TypeScript and I'm facing an issue when trying to use a value I created in my context API. I keep getting the error message "Property 'sidebar' does not exist on type 'IStateContext | null'", even though it exis ...

Access file using operating system's pre-installed application

How can I open a file using the default application for that file type on different operating systems? For example, when opening an image.png on Mac, it should open with Preview, and on Windows with Windows Photo Viewer. I know you can use open image.png ...

Using Firebase: retrieving getAdditionalUserInfo in onCreate of a Firebase Cloud function

Can anyone help me figure out how to retrieve extra data from a SAML login provider in the backend (firebase functions)? I can see the data on the client side but I'm struggling to access it in the backend. I've specified these dependencies for ...

Trigger a function upon a user's departure from a page or route in Angular 2

Is there a way to trigger a function only when the current route changes away from a specific component, such as when navigating away from "..../user/user-details"? I want this method to execute regardless of whether the route is changed through user inter ...

Encountering a "No such file" error when attempting to execute an Angular application as a

The Angular project's main folder houses the Dockerfile, along with package.json and other files. The Dockerfile structure is as shown below: FROM node:lts-alpine AS builder WORKDIR /app COPY . . RUN npm install RUN npm run build FROM nginx:alpine COP ...

Can you explain the concept of injection context within Angular version 16 and later?

I have come across the term "Injection context" and am trying to understand what it entails. In Angular, there are several things that are connected to injection context: EnvironmentInjector#runInContext injectionContext runInInjectionContext inject() Fr ...

Instructions for utilizing a specific router-outlet within a main router-outlet:

I have a main router-outlet within my side-nav component, and I have created two additional router-outlets inside it. This is the structure: router-outlet (main) { router-outlet name='info' { } router-outlet name='servic ...

Extracting data from an action using NgRx8

Hey everyone, I'm looking for some guidance on how to destructure action type and props in an ngrx effect. I'm struggling with this and could use some help! This is my list of actions: export const addTab = createAction( '[SuperUserTabs ...

Creating an array of custom objects in Typescript involves declaring a class that represents the custom

module NamespaceX{ interface Serializable<T> { deserialize(input: Object): T; } export class CustomClass implements Serializable<CustomClass>{ private property1: number; private property2:string; con ...

What is the reason behind TypeScript requiring me to initialize a property even though I am retrieving its value from a local reference?

I am just beginning to explore Angular. This is the template for my custom component: <div class="row"> <div class="col-xs-12"> <form action=""> <div class="ro"> <d ...

Error: Attempted to call the 'post' method on an undefined object, resulting in an Uncaught TypeError. This occurred within the Ionic 2 framework while executing the Javascript code located

While I attempt to convey my message in English, unfortunately, it is not a language I am fluent in. Currently, I am working on an Ionic 2 project. In this particular scenario, I am trying to make an HTTP request using the POST method while emulating it o ...

``There seems to be an issue with the Deno logger FileHandler as it

I am currently in the process of setting up loggers for an application. I have a handler named console which logs every event to the console. Additionally, there is a handler called app that is supposed to log all events to a file. While the logs are succ ...

Utilize cypress to analyze the loading time of a webpage

My current challenge involves using cypress to carry out website tests. I am looking for a reliable method to measure the duration it takes for certain cypress commands to load or execute. As an example: //var startTime = SomeStopwatchFunction(); cy.visit( ...

The value is not being displayed by ngModel

When working with HTML, I encountered an issue where the ngModel was not displaying even though the selectedValueModel was already assigned. I also tried using [ngValue], which resulted in the value being passed as undefined to my ngModelChange function. ...

Discover the inverse of Object Arrays interaction in TypeScript

My agent object has the following structure: agentObj = { "agentId": "saqib", "attributes": [ { "name": "Marketing", "type": "Boolean", }, { "name": "English", "type": "Profi ...