2017-06-29 29 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選擇「對話」是從我使用的圖書館之一選擇一個命名空間衝突。我改變了名稱,它的工作。

相關問題