如果从dataplotClick事件回调中打开,则首次单击时不会打开Angular MatDialog

时间:2019-11-12 16:00:54

标签: angular-material angular7 fusioncharts

当我单击融合图项目时,我正在尝试打开MatDialog,我的问题是对话框在第一次单击时无法正确打开,但是当我再次单击它时,打开对话框时我没有这个问题单击常规按钮对话框

这是我的融合图表代码

<fusioncharts [dataFormat]="dataFormat" [dataSource]="dataSource" [events]="events" [height]="height"
                [type]="type" [width]="width">
            </fusioncharts>

这是我的活动:

ngOnInit() {
    let that = this;
    this.events = {
        dataplotClick: (event, data) => {
            const id = data.id;
            that.openDialog(id);
            event.stopPropagation();
        }
    };
}

openDialog(id) {
    const reg = this.dataSource.dataset[0].data.filter(data => data.id === id)[0];
    const devices = [];
    devices.push(reg.id_device);
    let deviceID = devices[0];
    localStorage.setItem('devicesForRegulation', JSON.stringify(devices));
    localStorage.setItem('espaceForRegulation', reg.id_espace);
    console.log('hi')
    let dataD = this.serre.filter(serre => serre.id === reg.id_espace)[0];
    let mode = [];
    for (let device of dataD.devicesData) {
        if (device.id_device === deviceID) {
            device.action = '0';
            mode = device;
            break;
        }
    }

    const dialogRef = this.dialog.open(AppScadaRegulationComponent, {
        width: window.innerWidth < 720 ? '100%' : window.innerWidth / 1.7 + 'px',
        height: window.innerWidth < 720 ? '100%' : 'auto',
        data: mode,
        maxWidth: 'none'
    });

    dialogRef.afterClosed().subscribe(result => {

    });
}

任何帮助人员

0 个答案:

没有答案