2017-12-08 8 views
0

ダイアログのチュートリアルに従うと 私はこの問題を解決するために何をすべきかというアイデアがある場合、上記のエラーが発生していますか? ここ角度4/5のキャッチしていないエラー:テンプレートの解析エラー: 'mat-dialog-close'にバインドできません。 'button'の既知のプロパティではありません。

は私のコードです:モーダル

<h1 mat-dialog-title>Warning</h1> 

<div mat-dialog-content> 
    <p>Are you sure you want to delete the book {{data.title}} ?</p> 

</div> 
<div mat-dialog-actions> 
    <button mat-button [mat-dialog-close]="data.title" tabindex="2">Ok</button> 
    <button mat-button (click)="onNoClick()" tabindex="-1">No Thanks</button> 
</div> 

ため HTMLクラスアクティブモーダルこと:

import { Component, OnInit, Inject } from '@angular/core'; 
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; 
@Component({ 
    selector: 'app-remove-book', 
    templateUrl: './remove-book.component.html', 
    styleUrls: ['./remove-book.component.scss'] 
}) 
export class RemoveBookComponent implements OnInit { 


    constructor(
    public dialogRef: MatDialogRef<RemoveBookComponent>, 
    @Inject(MAT_DIALOG_DATA) public data: any) { } 

    onNoClick(): void { 
    this.dialogRef.close(); 
    } 


    ngOnInit() { 
    } 

} 

and the method in the class that supposes to active the modal: 
    removeContact(i){ 


    let dialogRef = this.dialog.open(RemoveBookComponent, { 
     width: '250px', 
     data: { ok: this.ok, title: this.contactsArr[i].title } 
    }); 

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

     console.log('The dialog was closed'); 

     this.contactsArr.splice(i,1); 


    }); 


     } 

は、私は必要なすべての輸入を行なったし、誰かが助けることができるならば、それは動作するはずです私はとても感謝しています。

ありがとうございました。まあ

+0

パッケージをモジュールにインポートしましたか?このコンポーネントは? –

答えて

0

私はgitの上にそれを尋ねた後、私は私の問題を発見し、それがあった: インポートする - > MatDialogModule を、私はそれだけでそれをチェックアウト 間違っていたかのアイデアを与える場合でも、誰かを助けることを願っています: https://github.com/angular/material2/issues/8911

関連する問題

 関連する問題