Skip to content

feat(modal): add markForCheck for modal (#UIM-262) #349

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/mosaic-dev/modal/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class ModalDemoComponent {
window.setTimeout(() => {
const instance = modal.getContentComponent();
instance.subtitle = 'sub title is changed';
modal.markForCheck();
}, 2000);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/mosaic/modal/modal-ref.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ export abstract class McModalRef<T = any, R = any> {
* Get the instance of the Modal itself
*/
abstract getInstance(): McModalComponent;

/**
* Call markForCheck for change detector
*/
abstract markForCheck();
}
7 changes: 6 additions & 1 deletion packages/mosaic/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ export class McModalComponent<T = any, R = any> extends McModalRef<T, R>
private viewContainer: ViewContainerRef,
private modalControl: McModalControlService,
private changeDetector: ChangeDetectorRef,
@Inject(DOCUMENT) private document: any) {
@Inject(DOCUMENT) private document: any
) {

super();
}
Expand Down Expand Up @@ -249,6 +250,10 @@ export class McModalComponent<T = any, R = any> extends McModalRef<T, R>
this.close(result);
}

markForCheck() {
this.changeDetector.markForCheck();
}

triggerOk() {
this.onClickOkCancel('ok');
}
Expand Down