The ngModal in Angular opens successfully, but users are unable to interact with any input fields or buttons

Issue: I am encountering a problem with a button inside a component that is supposed to open another component as a modal. The button successfully opens the modal, but I am unable to interact with any elements inside it, including inputs and the close button (cross). I have already included the component as an entryComponent in the App module:

entryComponents: [NeworderComponent]

Code snippet for the component triggering the modal window (.html)

<button type="button" class="btn btn-success text-center" (click)="openew(rank?.productId)">Order</button>

Code snippet for the component triggering the modal window (.ts)

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';

export class TopproductsComponent implements OnInit {

  constructor(private orderservice: OrderService,
    private productService: ProductService,
    private activatedRoute: ActivatedRoute,
    private modalService: NgbModal,
    private router: Router) { }

    openew(id) {
        const modalRef = this.modalService.open(NeworderComponent, {size:"lg"});
        modalRef.componentInstance.title = 'neworder';
      }
}

Code snippet for the modal component (.html)

<div class="modal-dialog modal-lg">
  <div class="modal-header">
    <h4 class="modal-title">New Order</h4>
    <button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <div class="modal-body">
    <div class="mt-3">
      <form #new="ngForm" class="mt-3 text-center" id="form" (ngSubmit)="onSubmit(new)">
        <div class="text-center">
          <div class="form-group">
            <label for="prod_edit">Product</label>
            <select class="form-control" [(ngModel)]="product" [ngModelOptions]="{standalone: true}">
              <option *ngFor="let product of products" value="{{ product?.id }}">{{ product?.name }}</option>
            </select>
          </div>  
          <div class="form-group">
            <label for="exampleFormControlInput1">Quantity</label>
            <input type="text" name="quantity" class="form-control text-center mt-2" [(ngModel)]="quantity" [ngModelOptions]="{standalone: true}">
          </div>
        </div>
        <button type="submit" class="btn btn-success w-50 mt-2">Submit</button>
      </form>
    </div>
  </div>
</div>

Code snippet for the modal component (.ts)

import { Component, OnInit, Input} from '@angular/core';
import { NgbActiveModal} from '@ng-bootstrap/ng-bootstrap';

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


export class NeworderComponent implements OnInit {
  @Input() title = `Information`;

  constructor(private orderservice: OrderService,
    private productService: ProductService,
    public activeModal: NgbActiveModal) { }

  ngOnInit() {
    this.productService.getProducts().subscribe(products => {
      this.products = products;
      console.log(this.products);
    });
  }
}

Answer №1

To remediate the issue, it is necessary to eliminate the modal-dialog modal-lg class from the primary div of your component (you may even delete the div altogether).

<div> <!--this should NOT be <div class="modal-dialog modal-lg"> -->
 <div class="modal-header">
  ....
  </div>
  <div class="modal-body">
  ...
  </div>
<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

I am sorry, but it seems like there is an issue with the definition of global in

I have a requirement to transform an XML String into JSON in order to retrieve user details. The approach I am taking involves utilizing the xml2js library. Here is my TypeScript code: typescript.ts sendXML(){ console.log("Inside sendXML method") ...

When using react-admin with TypeScript, it is not possible to treat a namespace as a type

Encountering issues while adding files from the react-admin example demo, facing some errors: 'Cannot use namespace 'FilterProps' as a type.' Snippet of code: https://github.com/marmelab/react-admin/blob/master/examples/demo/src/orde ...

An issue has been detected with the width attribute in Typescript when using

I have a question regarding the TypeScript error related to the width property. I've created a component called ProgressBar where I'm using Stitches for styling. However, TypeScript is throwing an error even when I specify the type as ANY. impor ...

Result from Nativescript ModalView

crongoramaModal() { let options = { context: {}, fullscreen: true, viewContainerRef: this.viewRef }; this.modalService.showModal(CronogramaManejoComponent, options) .then((result: CronogramaManejo)=>{ ...

Challenges encountered when implementing a personal library in a separate project

After updating a library I own, I seem to have encountered an issue when trying to use it in another project. However, the reason for this problem eludes me. A multitude of error logs with a similar theme are appearing: ERROR in ./node_modules/@company-na ...

What could be causing the "ng not found" error as I try to deploy my Angular application on Heroku?

Here is the structure of my project: package.json (A) index.js client > package.json (B) This is how the outer package.json (A) is set up : { "name": "---", "version": "1.0.0", "description": "---", "main": "index.js", "scripts": { "sta ...

Ways to incorporate an image inside renderCell when printing the MUI X data-grid

Using MUI X data-grid, I have created a grid to display data with the help of renderCell. My goal is to print the data grid and have the image from the first renderCell displayed prominently. const columns: GridColDef[] = [ { field: 'p ...

MatIconRegistry import error in Angular Material

Currently, I am using 'Angular: 10.0.14' along with '@angular/material 10.2.7'. However, when attempting to import MatIconRegistry, I encountered the following error message: ERROR in node_modules/@angular/material/icon/icon-registry.d ...

Ensure the CSS class stays on Quill clipboard.dangerouslyPasteHTML

One of the challenges I face with using the Quill Text Editor is that when I use the method clipboard.dangerouslyPasteHTML to paste HTML into the editor, it does not maintain custom CSS classes. For example: let content= '<p class="perso-clas ...

Exploring the Power of Buttons in Angular 2

I have a scenario where I need to implement two different buttons in my template. The first button is as follows: <button [style.background-color]="service_rec.status == 'Online' ? 'green' : 'red'" class="btn btn-defa ...

Exploring the async/await functionality in TypeScript

Hey there! I'm working with this Angular/TypeScript service, and I've run into an issue where the query part of the function is asynchronous. This means that the return statement gets executed before the data is actually retrieved from the serve ...

Having difficulty troubleshooting the /app router application on version 13.4.x

Having trouble debugging a server-side process in my Next.js app that uses the /app router. To reproduce the issue, simply create a new Next.js app with npx create-next-app and select the app router option. I've attempted to attach a debugger to the ...

Failing to retrieve the file instance upon completing the upload process to cloudinary using nestjs

I am attempting to retrieve the secure file URL provided by Cloudinary after successfully uploading the asset to their servers. Although I can upload the file to Cloudinary, when I try to view the response using console.log(res), I unfortunately receive &a ...

Typescript: Implementing a generic function with the flexibility of an optional parameter

Having some difficulty writing a generic function with an optional parameter type Action<TParameters = undefined> = (parameters: TParameters) => void const A: Action = () => console.log('Hi :)') // This works as expected const B: ...

The Bootstrap 4 dropdown feature is not functioning properly in Angular's production environment

While developing my Angular application with Bootstrap 4, I encountered an issue with the dropdown functionality. In the development mode, everything works perfectly. However, in production mode, I received the following error: Uncaught Error: DROPDOWN: ...

Error during Next.js build: Incompatible types - cannot assign type to 'never'

Encountering an error in the console while attempting to build my project: .next/types/app/facebook/page.ts:8:13 Type error: Type 'OmitWithTag<typeof import("D:/projects/abkh24/client/app/facebook/page"), "metadata" | "defa ...

Creating and updating a TypeScript definition file for my React component library built with TypeScript

As I work on developing a React library using TypeScript, it is important to me that consumers of the library have access to a TypeScript definition file. How can I ensure that the TypeScript definition file always accurately reflects and matches the Java ...

Dynamic Autocomplete Text Input featuring API-supplied Array in Angular

Currently, I am exploring the process of populating a text box with user emails obtained through an API call to the server. select-users.component.html: <input type="text" placeholder="Email Search" aria-label="Email" matInput [form ...

Angular 8: Implementing unique service instances for each instance of a shared component

In my current project, I am working on developing reusable d3-based dashboard components within Angular 8. The goal is to create components such as a barchart that can be easily packaged into a module and reused without requiring any modifications to the c ...

Angular Material Spinner with Custom Image Icons - (mat-spinner)

I have successfully implemented the mat-spinner in my project with configurable changes like color and mode of spinning. However, I am now looking to add an image icon, specifically the logo of a brand or company, inside the spinner. How can I achieve this ...