我需要从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' });