【发布时间】:2023-03-12 03:26:01
【问题描述】:
刚刚开始构建 Angular 应用程序。我正在编写一个小型图书库存应用程序。我在使用 Material Module 中的 Dialog 组件 时遇到问题。我访问了 Angular 材料网站以检查我的实现,但仍然无法让它按预期运行。我在 snackbar 组件 上遇到了类似的问题。想知道是否有人以前遇到过这个问题。感谢您的帮助!
app.Module.ts
import {MatDialogModule } from '@angular/material/dialog';
imports:[MatDialogModule]
collection.component.ts
import {MatDialogModule, MatDialogRef } from '@angular/material/dialog';
bookDetailDialogRef: MatDialogRef<BookDetailComponent>;
constructor(private dataService: DataService, private snackBar: MatSnackBarModule,
private _dialog: MatDialogModule, private _router: Router){}
openDialog(bookId: number): void{
let config = {with: '650px', height: '400px', position: {top: '50px'}};
let dialogRef = this._dialog.open(this.bookDetailDialogRef, config);
dialogRef.componentInstance.bookId = bookId;
dialogRef.afterClosed().subscribe(res => {this.getBooks();});
}
collection.component.html
<button mat-button (click)="openDialog(book.id)"><i class="material-icons">
pageview</i> Dialog</button>
【问题讨论】:
标签: javascript html css angular angular-material