У меня есть таблица со многими строками, определенными в компоненте, который я хочу добиться, чтобы при нажатии строки в таблице отображалось модальное окно (диалог). Поэтому я создал отдельный компонент для диалога, но он не работает.
код компонента таблицы здесь (соответствующие части)
import { SwatModalComponent } from '../swat-modal/swat-modal.component';
modal: SwatModalComponent;
constructor(private alertService : AlertService) {
if(alertService.filteredParam){
//we have a filtered processAlertSwitchName
this[alertService.filteredParam.name] = alertService.filteredParam.value;
alertService.filteredParam = null;
}
this.registerEvents();
this.modal = new SwatModalComponent();
}
showModal() {
this.modal.showDialog();
}
Код диалога в основном скопирован из документа
import { Component, OnInit } from '@angular/core';
import {DialogModule} from 'primeng/primeng';
@Component({
selector: 'app-swat-modal',
templateUrl: './swat-modal.component.html',
styleUrls: ['./swat-modal.component.sass']
})
export class SwatModalComponent implements OnInit {
display: boolean = false;
showDialog() {
this.display = true;
}
constructor() { }
ngOnInit() {
}
}
и html код здесь
<p-dialog header="Alert Dialog" [(visible)]="display" modal="modal" width="300" responsive="true">
<header>
Header content here
</header>
Content
<footer>
Footer content here
</footer>
</p-dialog>
при отладке я вижу, что для атрибута отображения SwatModalComponent установлено значение true, но на экране не появляется модальное окно.