Angular 4's Mddialog experiencing intermittent display problem

While using MDDialog in my Angular app, I've encountered a couple of issues. Whenever a user clicks on the div, flickering occurs. Additionally, if the user then clicks on one of the buttons, the afterclose event is not triggered.

Can anyone provide suggestions on how to address these problems?

Here is the code snippet for calling the dialog:


private openDialog(data) {

    const dialogRef = this.dialog.open(DialogComponent, { width: 
            '350px', height: '100px', disableClose: true});
    dialogRef.updatePosition({ top: '95px' });

    dialogRef.afterClosed().subscribe(result => {

        this.dialogResult = result;

        console.log('dialogResult : ' + this.dialogResult);

        if (this.dialogResult) {
            this.Home();
        }

    });
    this.dialogResult = '';
 }

Dialog HTML:


<div md-autofocus>
   <div md-dialog-container>
   <h2 md-dialog-title>Information</h2>
   <md-dialog-content> Do you want to proceed? </md-dialog-content>
   <div md-dialog-actions>
      <div class="dialogButtons">
         <button  id= "YesButton" class="dialogButton"
            (click)="dialogRef.close(true)">Yes</button>
         <span class="flex1margin"></span>
         <button   id="NoButton" class="dialogButton"  
            (click)="dialogRef.close(false)">No</button>
         </div>
       </div>
     </div>
 </div> 

Dialog Component TypeScript:


import { Component, OnInit } from '@angular/core';
import { MdDialogRef } from "@angular/material";

@Component({
selector: 'your-dialog-selector',
templateUrl: './dialog.component.html'
})
export class DialogComponent {
     constructor(public dialogRef: MdDialogRef<any>) {
  }
}

Answer №1

A mistake was made when attempting to call the .close() method on the dialog object. Instead of using dailogRef, it should be dialogRef

 <button  id= "YesButton" class="dialogButton"
    (click)="dailogRef.close(true)">Yes</button>
 <span class="flex1margin"></span>
 <button   id="NoButton" class="dialogButton"  
    (click)="dailogRef.close(false)">No</button>
 </div>

This code should actually look like this:

 <button  id= "YesButton" class="dialogButton"
    (click)="dialogRef.close(true)">Yes</button>
 <span class="flex1margin"></span>
 <button   id="NoButton" class="dialogButton"  
    (click)="dialogRef.close(false)">No</button>
 </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

Performing an Axios POST request in a React Native and React app using JSON.stringify and Blob functionality

I am currently developing an application where I have encountered an issue when calling an API endpoint in react native. Interestingly, the web app (built with React) does not encounter any errors. Here is the code for the web app using React with TypeScri ...

What is the best way to utilize AJAX to send a value from a foreach loop in Laravel?

I'm encountering an issue where all forms are sending the value as if it's from the first form, however, my intention is for each form to send the data inside it when I press the send button. Blade @foreach($car_lists as $car_list) <li class= ...

How can I resize an element using jQuery resizable and then revert it back to its original size with a button click?

I need help figuring out how to revert an element back to its original size after it has been modified with .resizable. I attempted the following: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="//code. ...

What is the process for testing and executing the code I've written on ACE Cloud 9?

I have integrated ACE on my website to enable users to code freely. My question is, how can I execute the Python code they write? I want to add a run button in the bottom left corner (which I can style using CSS), but I'm not sure how to actually run ...

Having trouble with Angular JS's ngRoute feature not functioning properly

I've been struggling with my ngRoute implementation. I seem to be unable to load the 'ngRoute' module for some reason. Whenever I run this code, I just end up with a blank page. Below is my app.js file: var app = angular.module('tutor ...

Using multiple jQuery dialogs on index.php

I have a vision for my website to mirror the Windows environment, complete with icons that prompt dialog boxes when clicked. On my site's index page, I've added the following code within the head tags: <link rel="stylesheet" href="http://cod ...

Trouble getting proper alignment displayed with JavaScript and CSS

If anyone has a solution for printing content in a div using JavaScript and CSS, please help. The main div with the id 'preview' contains content taken from a database using PHP and MySQL. However, the data on the print page appears vertically an ...

Scrolling down a jQuery div after each new item is added.OR

I have a div acting as a chat feature, where messages are appended based on user actions. I am trying to make it so that the div automatically scrolls down after each message is added, but I'm encountering some issues with this functionality. You can ...

What is the best way to have a text field automatically insert a hyphen after specific numbers?

Is there a way to make a text field insert hyphens automatically after certain numbers? For example, when typing a date like 20120212, could we have the input automatically formatted with hyphens after the first 4 digits and the second two, so it displays ...

The FaceBook SDK in React Native is providing an incorrect signature when trying to retrieve a token for iOS

After successfully implementing the latest Facebook SDK react-native-fbsdk-next for Android, I am facing issues with its functionality on IOS. I have managed to obtain a token, but when attempting to use it to fetch pages, I keep getting a "wrong signature ...

Switch to a different element by rolling over one

I need assistance with a menu setup where the submenus are located in separate divs on the page. Both the parent elements and submenus have numerical identifying IDs, and I am struggling to create a rollover effect that would automatically open the corresp ...

Developing a universally accessible variable for utilization in various functions

I'm having trouble understanding why 'currentPos.LatLng' is undefined when trying to access it outside the function even though it's part of an object. I want to be able to retrieve the current position values to use them in another fun ...

I require the ability to retrieve only the data from a UI grid column, specifically based on the column name selected

I need help with my angularjs application that utilizes Ui grid. There is an external dropdown menu located outside of the ui grid, which lists all the column names in the grid. I want to be able to select a specific column name from this dropdown and retr ...

Utilizing interface in NestJS for validating incoming request parameters

My goal is to utilize the interface provided by class-validator in order to validate a specific field in the incoming request body. Here's the interface structure: export enum Fields { Full_Stack_Dev = 'full stack dev', Frontend_Dev = &a ...

Developing in VS Code and Angular: How to create a component without a spec file

Hello fellow developers! I am currently using the latest version of VS Code for my Angular application. One feature I have been utilizing is the ability to right-click a folder and select "New component" to quickly and easily create a new Angular componen ...

Personalizing the pop-up window using window.open

When clicking a hyperlink on a page, I need to open multiple pop-up windows. To achieve this, I must use the Window.open function instead of showModalDialog. However, I have noticed that the appearance is not satisfactory when using Window.open. (Essentia ...

Ways to update the component's state externally

I'm new to Next.js (and React) and I'm attempting to update the state of a component from outside the component. Essentially, I am conditionally rendering HTML in the component and have a button inside the component that triggers a function to se ...

Include a header in the API HTTP call for Angular 2 and Ionic 2

Working on my Ionic 2 app, I am using Angular 2 Http to retrieve JSON from an API. However, I am struggling to send the app-id, app-key, and Accept as headers in the main code snippet below: import {Component} from '@angular/core'; import {NavC ...

Which element from the context menu has been selected?

We specialize in creating browser extensions for Chrome, Firefox, and Safari. Our latest project involves implementing context menus within the extensions that will appear when users right-click on any editable form element. I attempted to incorporate an e ...

Use Jquery to apply quotation marks within a blockquote

Here is the code I am working with: $("input[id="+id.slice(0,-1)+"-br-"+brand+"].qnt_to_cart").show(); This code generates: input[id=02620-br-FEBI BILSTEIN].qnt_to_cart However, I need it to look like this instead: input[id="02620-br-FEBI BILSTEIN"].q ...