I am facing an issue with the Angular2 Modal Form where it only displays the data but does

Hey there,

I recently started diving into Angular and I'm loving the learning process.

Currently, I've managed to successfully load a form into my Modal when clicking on "viewDetails".

However, as soon as I modify the Form from <form ngNoForm > to

<form #editCashMovementForm="ngForm">
, the data stops loading.

I'm aiming to create an editable pop-up form that updates upon submission, but I seem to be stuck at this final hurdle.

If anyone has any advice or guidance, please share!

Thank you

Gws

Component.HTML

<div>
    <table class="table table-hover">
        <thead>
            <tr>
                <th><i class="fa fa-text-width fa-2x" aria-hidden="true"></i>Cash Movement ID</th>
                <th><i class="fa fa-user fa-2x" aria-hidden="true"></i>PortfolioCode</th>
                <th><i class="fa fa-paragraph fa-2x" aria-hidden="true"></i>CCY Out</th>
                <th><i class="fa fa-map-marker fa-2x" aria-hidden="true"></i>Account Out</th>
                <th><i class="fa fa-calendar-o fa-2x" aria-hidden="true"></i>Date</th>
                <th></th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let cashmovement of cashmovements">
                <td> {{cashmovement.cashMovementId}}</td>
                ... (data continues)
            <td><button class="btn btn-primary" (click)="viewCashMovementDetails(cashmovement.cashMovementId)"><i class="fa fa-info-circle" aria-hidden="true"></i>Edit</button></td>
            </tr>
        </tbody>
    </table> 
</div>

<div bsModal #childModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    ... (data continues)

Component.ts

import { Component, OnInit, ViewChild, Input, Output, trigger, state, style, animate, transition } from '@angular/core';
... (component.ts content)

data.service.ts

    import { Injectable } from '@angular/core';
    ... (data.service.ts content)
    }

Answer №1

I am looking to make a modification to my form input fields by updating them with the following changes:

<input type="text" class="form-control" [(ngModel)]="cashmovementDetails.portfolioCode" />

Transforming into:

<input type="text" class="form-control" [(ngModel)]="cashmovementDetails.portfolioCode" name="portfolioCode" #portfolioCode="ngModel"/> 

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

Are there specific files or classes that store constants for different keyboard events?

When working in Angular, I often bind data with a host listener using code similar to the example below: @HostListener('window:keyup', ['$event']) onKeyUp(event: KeyboardEvent) { if (event.keyCode === 13) { this.onEnterClicked(ev ...

Looking for guidance on implementing explicit waits in Protractor for non-angular applications

I have noticed that automating non-angular applications with Protractor can be challenging. Currently, I am using some methods to add an explicit wait to my existing Serenity click and enter functions. However, I am curious if there is a way to automatic ...

When trying to gather multiple parameters using @Param in a NestJS controller, the retrieved values turn out

Can someone help me understand why I am struggling to retrieve parameters using the @Param() decorators in my NestJS controller? These decorators are defined in both the @Controller() decorator argument and the @Get() argument. I am relatively new to Nest ...

Production environment experiencing issues with Custom Dashboard functionality for AdminJS

I have successfully integrated AdminJS into my Koa nodejs server and it works perfectly in my local environment. My objective is to override the Dashboard component, which I was able to do without any issues when not running in production mode. However, wh ...

The Typescript code manages to compile despite the potential issue with the type

In my coding example, I have created a Try type to represent results. The Failure type encompasses all possible failures, with 'Incorrect' not being one of them. Despite this, I have included Incorrect as a potential Failure. type Attempt<T, ...

Tips for customizing a generic repository error message

I have a GenericRepository class that provides basic functionality for interacting with persistence storage such as creating, finding, getting all, deleting, and updating data. Within the find method, I am searching the database using its primary key. If ...

Configuring mobile devices for a sliding form using jQuery

After building a form based on the tutorial from (http://tympanus.net/Tutorials/FancySlidingForm/) for my website, I encountered some issues. While it works well on my computer and adjustments were made for responsiveness on tablets and smartphones using r ...

Choose the Angular 2 option

I am having an issue with the select option in my code. The person's gender property is assigned 'M' for male, but I need to allow users to change it to 'F' for female. Here is the HTML code snippet: <span > <span &g ...

The functionality of this.router.navigate in Angular 15 seems to be off, as it is throwing an error saying it is not

Just have a quick question: Check out this code snippet... import { DOCUMENT } from '@angular/common'; import { Component, HostListener, Inject, NgZone } from '@angular/core'; import { Router } from '@angular/router'; @Compo ...

ts1109: An error occurred as there was an expectation for an angular

I am encountering an error while creating a simple form with Angular using a reactive form. I'm puzzled as to why it's indicating that something is missing: Although I have created forms numerous times before, this is the first instance of such ...

Enhance your FullCalendar experience with React by displaying extra information on your calendar

I am new to using React and FullCalendar, and I have a page layout similar to the image linked below. https://i.sstatic.net/MooTR.png Additionally, I have a list of events structured as shown: id: "9", eventId: "1", ...

Different Types of Buttons in HTML

As someone who is new to the world of HTML coding and JavaScript, I have a question about button types. According to the W3Schools website, there are three types of buttons: <button type="button|submit|reset"> First question: Why do we need a for ...

Utilizing the <HTMLSelectElement> in a Typescript project

What exactly does the <HTMLSelectElement> do in relation to a TypeScript task? let element = <HTMLSelectElement> document.querySelector('#id_name'); The HTMLSelectElement interface, similar to the one mentioned in TypeScript, is exp ...

Using Angular BehaviorSubject in different routed components always results in null values when accessing with .getValue or .subscribe

I am facing an issue in my Angular application where the JSON object saved in the service is not being retrieved properly. When I navigate to another page, the BehaviorSubject .getValue() always returns empty. I have tried using .subscribe but without succ ...

Can you explain the true meaning behind this specific type definition?

Since starting to dive into TypeScript recently, I came across an express server written in TS while browsing the Internet. However, I am struggling to comprehend the type definition of the 'middlewares' argument. Despite attempting to research i ...

Angular nested innerHTML not evaluating ternary operator

Here is a code snippet that I am struggling with: {{ Name && Name.length > 20 ? (Name | slice: 0:20) + "..." : Name }} The above code works fine when used inside a div, but when I try to use it within innerHTML, I encounter a syntax e ...

Creating a React component in Typescript to utilize lodash helper functions

I have a component that looks like this: import React, { Component } from 'react'; import throttle from 'lodash.throttle'; interface Props { withScroll: boolean; } class Image extends Component<Props, {}> { throttledWindowS ...

Enhance Summernote functionality by creating a custom button that can access and utilize

Using summernote in my Angular project, I am looking to create a custom button that can pass a list as a parameter. I want to have something like 'testBtn': this.customButton(context, listHit) in my custom button function, but I am unsure how to ...

Creating a channel for communication between sibling components in Angular 4 by storing component references in a shared service

I am searching for a way to establish communication between two sibling Angular 4 components. After reviewing the documentation at https://angular.io/guide/component-interaction, my idea revolves around utilizing a service that stores a reference to the c ...

What is the proper way to define a generic function that accepts a Union type as an argument?

I am dealing with various types and their unions. Here is the code snippet: type A = { name: string } type B = { work: boolean } type AB = A[] | B[] const func = (): AB => { return [{ name: 'ww' }] } const data = ...