[英]How can I open Modal by clicking a custom button angular
我在分離的組件中創建了一個自定義按鈕,這允許我在我想要的地方添加這個組件(按鈕)。
例如,這是自定義組件按鈕:
AddBtn.component.html:
<button nbButton status="primary" onclick="openModal()">Affect TPE</button>
AddBtn.component.ts
@Component({
selector: "ngx-nb-list",
templateUrl: "./nb-list.component.html",
styleUrls: ["./nb-list.component.scss"],
})
export class NbListComponent implements OnInit {
constructor(private dialogService: NbDialogService) {}
ngOnInit() {
}
openModal() {
this.dialogService.open(AddUsercComponent);
}
}
我想在主組件中顯示按鈕,比如在 home 中添加按鈕,點擊它我想顯示一個模式
對於那些好奇的人:我正在研究 ngx-admin,我不允許在單元格中添加按鈕,所以我必須做這樣的事情
在 Angular 中調用 click 函數時,您應該使用正確的 click 指令。 你的代碼應該是這樣的:
<button nbButton status="primary" (click)="openModal()">Affect TPE</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.