There was a problem when adding a modal window component to angular 2. A window is being created, but not a dialog.

Screen

dialogue screen

It is added as a regular div block. What could be the problem?

app.module.ts

import { MaterialModule } from '@angular/material'; @NgModule({ declarations: [ ... DialogComponent ], imports: [ ... MaterialModule.forRoot() ] }) 

dialog.component.ts

 import { Component, ViewContainerRef } from '@angular/core'; import { MdDialog, MdDialogConfig, MdDialogRef } from '@angular/material'; import { DialogComponent } from '../shared/dialog.component'; @Component({ moduleId: module.id, selector: 'dialog-page', templateUrl: 'dialog.component.html' }) export class SettingsComponent { dialogRef: MdDialogRef<any>; constructor(public dialog: MdDialog, public viewContainerRef: ViewContainerRef) { } open(key) { let config = new MdDialogConfig(); config.viewContainerRef = this.viewContainerRef; this.dialogRef = this.dialog.open(DialogComponent, config); this.dialogRef.afterClosed().subscribe(result => { this.dialogRef = null; }); } } 
  • It is added as a regular div block - how should it be added? - Grundy
  • @Grundy Maybe I wrote wrong. But I need a dialog box that opens on top of other elements. Now it is just below all other elements - Vadim Stetsyuk
  • it looks like you simply have no other elements. By the way, I don’t see in your module the entryComponents section - Grundy
  • And css position: absolute does not save the situation? - Olga Kramarchuk
  • one
    @Pantera, yes. You need to connect indigo-pink.css. Read Step 4: Include a theme material.angular.io/guide/getting-started - Vadim Stetsyuk

0