MatDialog通过http调用传递数据

时间:2018-06-28 17:59:56

标签: dialog material-design

我需要从Matdialog中的远程服务传递数据。我知道如何传递静态数据,但是如何通过订阅进行远程调用呢?

let dialogRef = this.dialog.open(DialogForm, {
    width: '60vw',
    data: { id: data.id, books: this.bookService.getBooks().subscribe(books => 
     {this.books = books}} // not working
});

constructor(public dialogRef: MatDialogRef<DialogForm>, @Inject(MAT_DIALOG_DATA) public data: any, public formBuilder: FormBuilder, private bookService: BookService) { }

 this.bookForm = new FormGroup({
      id: new FormControl(this.data.id),
      // I need to load the books here :
      books: new FormControl(this.data.books, {
        validators: Validators.required
      })
    }, { updateOn: 'change' });

0 个答案:

没有答案