2017-06-29 45 views
0

I'm not sure why the html inside of my dialog isn't displayedAngular4 MdDialog出现,但没有HTML显示在里面

这是我的应用程序和对话框组件。所有导入似乎都正常工作,并且我没有在浏览器控制台中收到任何错误消息。

import { Component, Input } from '@angular/core'; 
 
import {MdDialog, MdDialogRef} from '@angular/material'; 
 

 

 
@Component({ 
 
    selector: 'app-root', 
 
    templateUrl: './app.component.html', 
 
    styleUrls: ['./app.component.css'], 
 
}) 
 
export class AppComponent { 
 
    dialogRef : MdDialogRef<Dialog>; 
 
    title = 'Code Share app'; 
 
    admin = false; 
 
    userID : string = ""; 
 

 
    constructor(public dialog: MdDialog){ 
 
    this.openDialog(); 
 
    } 
 

 
    openDialog() { 
 
    this.dialogRef = this.dialog.open(Dialog); 
 
    this.dialogRef.afterClosed().subscribe(result => { 
 
    console.log(result); 
 
    this.dialogRef = null; 
 
    }); 
 
} 
 

 
} 
 

 

 
@Component({ 
 
    selector: 'dialog', 
 
    template: `<h1>Dialog</h1> 
 
    <div md-dialog-content>What would you like to do?</div> 
 
    <div md-dialog-actions> 
 
    <button md-button (click)="dialogRef.close('Option 1')">Option 1</button> 
 
    <button md-button (click)="dialogRef.close('Option 2')">Option 2</button> 
 
    </div> 
 
    <p>hello</p>`, 
 
}) 
 

 
export class Dialog { 
 
    constructor(public dialogRef: MdDialogRef<Dialog>){} 
 
}

回答

1

原来的HTML选择“对话”是从我使用的图书馆之一选择一个命名空间冲突。我改变了名称,它的工作。

相关问题