Transmitting form data inputted by the user to a modal that resides in the same component, all without the need for child or parent components or

In need of a solution where users can input answers to questions and have all the entered data displayed in a popup alongside the respective question. If a user chooses not to answer a question, I do not want that question or any related information to be shown. Suggestions were made about converting the entered data into a json object to achieve this, but I am unsure of how to proceed or if there is a better alternative. It is crucial for me to accomplish this within the same component.

I attempted to implement this using guidance from a resource How do I create popup with data user enters into a form?, without success. Furthermore, I aim to accomplish this task without creating additional components.

//This is the .html file

<div  ng-app="DemoApp" ng-controller="DemoController" class="form-row align-items-center">
    <div class="col-auto">
        <br />

        <div class="form-group">
            <label for="controlSelect1" >Select your tower...</label>
            <select class="form-control" name="exampleFormControlSelect1" formControlName="controlSelect1">
                <option></option>
                <option>Clown</option>
                <option>Championship</option>;                  
                <option>Other</option>
            </select>
        </div>

        <div class="form-group">
            // More form elements go here...

    </div>

<p>
    Form Value: {{ labForm.value | json }}
</p>

// More HTML code goes here...

//This is the .ts file

import { Component } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from'@angular/forms';

@Component({
selector: 'app-lab-access',
templateUrl: './lab-access.component.html',
styleUrls: ['./lab-access.component.scss']
})

export class LabAccessComponent {

// TypeScript code continues here...

The current format of the form data on the popup does not meet my expectations. Ideally, it should be structured as follows:

Requestor's Tower: Clown

Case Number: 328792892

Purpose of Visit: Felt like dropping by.

Needed Resources: Tool Cart

If a user leaves a question unanswered, I prefer it not to be part of the display.

Answer №1

My response to the inquiry was structured in a particular way. Utilizing a modal popup, the result is produced through the following snippet of code:

<div *ngIf="form.value.Num1">Part Number(s): {{form.value.Num1}}</div>

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

Positioning elements in CSS using percentages allows for flexible and responsive

I am new to web design and I am trying to create a webpage similar to the one shown in this image. However, I want to set the height and width of the divs using percentage values instead of pixels. Whenever I attempt this, the boxes end up overlapping or ...

Is there a way to make a model behave like an object in loopback when typing?

One of the challenges I face is dealing with a loopback model that is often represented in raw JSON format. For example: @model() class SomeModel extends Entity { @property({ type: 'string' }) id?: string; } In its raw JSON form, it would l ...

Is there a way to merge all this data into a single Object?

This particular situation is quite complex. Let's consider the following scenario: I have two JavaScript objects that are fetched via REST calls, using two different callbacks. So, we have: call1() - POST method - parsed JSON to JavaScript object, ...

Create boilerplate code easily in VS Code by using its feature that generates code automatically when creating a

Is there a way to set up VS Code so that it automatically creates Typescript/React boilerplate code when I create a new component? import * as React from "react"; export interface props {} export const MyComponent: React.FC<props> = (): J ...

What is the best way to share type definitions between a frontend and a Golang backend application?

I utilized typescript for both the frontend (Angular) and backend (Express). To ensure type definitions are shared, I created a file called shared-type-file.ts. interface Kid{ name: string; age: number; } By then running npm install in both the front ...

Change background according to URL query

My goal is to dynamically change background images based on a URL parameter, specifically the destination code. With numerous background images available, it's crucial to display the correct one depending on the URL string. For instance, if the URL re ...

Capturing Exceeding JSON Length Limit in ASP.NET MVC Serialization

I encountered an issue when trying to return a large JSON result: The string length exceeds the maxJsonLength property value set. I attempted to catch the exception during serialization, but it doesn't work as expected. try ...

TypeScript issue encountered with parseInt() function when used with a numeric value

The functionality of the JavaScript function parseInt allows for the coercion of a specified parameter into an integer, regardless of whether that parameter is originally a string, float number, or another type. While in JavaScript, performing parseInt(1. ...

Is it possible to create a pure CSS responsive square that is positioned to the top right of a div element of any size?

My current goal is to achieve the following task... I aim to position a square perfectly in one or both corners of the top right section of a div, ensuring it never exceeds the boundaries regardless of the div's size or dimensions that necessitate th ...

I am interested in using an image upload box that includes a hidden input field. However, I have encountered issues with the functionality when the input field is hidden. Does anyone have any suggestions on how

I have limited experience and need some assistance with resolving this particular issue. I am looking to create an image upload box that works when clicked on the input field. Thank you in advance. function readURL(input) { if (input.files && ...

Use the `string.replace()` method to swap out strings in a nested object with values from a separate file

Is there a way to swap out the placeholders __fruit_type__, __clothing_type__, __fitness_equipment__, __meditation_app__ in collection.js with the corresponding values from values.js? I'm attempting to do this using the string.replace() Method co ...

Saving individual pieces of data in the database

When it comes to storing single data values in a database, what is the most effective method? I have a few ideas. One option is to store all fields in a single_data_table with columns for id, key, and value. Another approach is to save it as a json object ...

Change a list into JSON format with Jackson library

After running the code mentioned below, I successfully converted a list to JSON with the following format: {"GodownMaster":[{"pname":"FCI CHARLAPALLI","pcode":"16042"}, {"pname":"MLS CIRCLE 1 L.B. NAGAR","pcode":"16016"},{"pname":"MLS CIRCLE 4 AZAMABAD", ...

The most effective way to code overlapping html buttons

Can you help me figure out how to make clickable areas on my HTML5 web page without them overlapping? Here's what I'm trying to do: I want the red, blue, and green areas to be clickable links, but not overlap. For example, when clicking on the f ...

Disable the button on smaller devices

I'm trying to make my button take up the full width on smaller screens like mobile devices. Here's what I have so far... Large Device https://i.sstatic.net/TJex1.png Medium Device https://i.sstatic.net/Hvkan.png Small Device https://i.sstatic ...

Is there a way to insert json data into a form input field using jQuery?

I am attempting to insert the JSON result into an input as the value. This is the code I am using: $.ajax({ type:"POST", url: '{% url "url_searchTour"%}', data: data1, success: function(jsonAjaxResult){ console.log(J ...

Attempting to evenly distribute items within a div container

My goal is to arrange the items in the container div evenly on a single line. I want them to be spaced out like this: I'm struggling to achieve this layout where the items are on the same line and evenly distributed within the available space. This ...

utilizing the data provided by a user in the "prompt" window within my HTML code

Looking to utilize user input from the prompt window. This is my custom JavaScript form: var answer; function load() { answer=prompt("what is your name?", "Write your name here"); return answer; } function hideNsee() { var HNS = docume ...

Modifying JavaScript Code in Inspect Element Editor

When I modify the HTML content using Chrome's Inspect Element editor, any changes made are immediately visible. However, when I make changes to the JavaScript code, the modifications do not take effect. For example, if I have a button that triggers a ...

Bootstrap's inline form features a button on a separate line from the rest of the form

I grabbed this code directly from bootstrap's official documentation: <form class="form-inline"> <div class="form-group"> <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label> <div class="inp ...