English 中文(简体)
材料方言
原标题:Material dialog pops up blank before showing letters on it
The bounty expires in 5 days. Answers to this question are eligible for a +50 reputation bounty. NickAth is looking for an answer from a reputable source.

我在我的电离应用中使用9.1.13 材料9.2.4。 我已注意到有关<>Matstrong>-Material Dialog部分的下述奇怪行为。

当我只用文字播放简单方言时, 方言首先空洞的继某些微秒(通常为300-1,000)之后,信封见。 放映情况如下:

一开始方言

“entergram

之后

“enterography

人口分布如下:

MyDialogComponent

export class MyDialogComponent {
public infoMessage: string;

constructor(
    @Inject(MAT_DIALOG_DATA) private data: any,
    private dialogRef: MatDialogRef<MyDialogComponent>
) {
    if (data) {
        this.infoMessage = data.message;
    }
}

public static getConfig(): any {
    return {
        width:  500px ,
        height:  auto ,
        disableClose: true,
        panelClass:  dialog-info ,
        backdropClass:  dialog-info-bg 
    };
}
}

我正在收集以下辩证:

const config = MyDialogComponent.getConfig();
config.data = {message:  My text that comes later than pop up };
this._dialogService.open(MyDialogComponent, config);

<>MatDialog

private _dialogService: MatDialog

www.un.org/Depts/DGACM/index_spanish.htm Html Code of MyDialogComponent

<div class="modal modal fade">
<div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="message">{{ infoMessage }}</h5>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn modal-btn close-btn">Close
            </button>
        </div>
    </div>
</div>

我在网上搜索了这一奇怪的行为,但还未找到任何令人满意的答案,说明如何处理这一问题。

问题回答

You may have an issue with change detection - Electron events and APIs don t trigger change detection in Angular. Try using ChangeDetect或RefNgZone:

imp或t { OnInit, ChangeDetect或Ref } from  @angular/c或e ;

...

exp或t class MyDialogComponent implements OnInit {
public infoMessage: string;

construct或(
    @Inject(MAT_DIALOG_DATA) private data: any,
    private dialogRef: MatDialogRef<MyDialogComponent>,
    private cdr: ChangeDetect或Ref
) { }

ngOnInit() {
    if (data) {
        this.infoMessage = data.message;
        this.cdr.detectChanges();
    }
}

imp或t { NgZone } from  @angular/c或e ;

...

exp或t class MyDialogComponent {
public infoMessage: string;

construct或(
    @Inject(MAT_DIALOG_DATA) private data: any,
    private dialogRef: MatDialogRef<MyDialogComponent>,
    private zone: NgZone
) {
    if (data) {
        this.zone.run(() => {
            this.infoMessage = data.message;
        });
    }
}

或者,你可以确保指挥部门对方言的改变进行适当的检测:

this.zone.run(() => {
    const config = MyDialogComponent.getConfig();
    config.data = {message:  My text that comes later than pop up };
    this._dialogService.open(MyDialogComponent, config);
});

If this resolves your problem, keep in mind f或 the rest of your app that anything coming from Electron will need the same handling in 或der to update the UI/rendered HTML.





相关问题
Angular matSort not working on Date column by desc

Trying to sort the material table with date column , date format is MM/DD/YYYY ,h:mm A , order of date is not by latest date and time. Anything which i missed from the below stackblitz code. https:/...

热门标签