Using MdDialogConfig data on Angular 2

前端 未结 3 1891
深忆病人
深忆病人 2021-01-13 10:37

I\'m trying to use a dialog component in Angular 2 using @angular/material2.0.0-beta.1. What I\'m trying to accomplish is to send data (which are values that a

3条回答
  •  囚心锁ツ
    2021-01-13 11:07

    Another way to do is to set the values from within the parent component DialogComponent

    @Component({
    selector: "dialog",
    templateUrl: "./dialog.component.html"
    })
    export class DialogComponent {
        constructor(public dialogRef: MdDialogRef) { }
        type: string;
        name: string;
        ngOnInit(): void {
    
       }
    }
    

    ParentComponent

    let dialogRef = this.dialog.open(DialogComponent);
    dialogRef.componentInstance.type= title;
    dialogRef.componentInstance.name= url;
    

提交回复
热议问题