我有一个非常简单的cdk
overlay
。但是我希望看到它的背景(用灰色或类似的颜色),当单击背景时,它应该关闭覆盖。
问题:
[hasBackdrop]="true"
时,我得到Can't bind to 'hasBackdrop' since it isn't a known property of 'ng-template'.
(backdropClick)="showAlert()"
根本行不通。<button (click)="showOverlay = !showOverlay"
#overlayOrigin="cdkOverlayOrigin"
cdkOverlayOrigin>
click me!!
</button>
<ng-template
cdkConnectedOverlay
[hasBackdrop]="false" //<=== Line A
(backdropClick)="showAlert()"
[cdkConnectedOverlayOrigin]="overlayOrigin"
[cdkConnectedOverlayOpen]="showOverlay">
<p class="dialog-container">hello</p>
</ng-template>