How to use scrollStrategy in MatDialog?

前端 未结 6 1221
独厮守ぢ
独厮守ぢ 2021-02-05 02:34

I tried to make a scroll for a dialog in reposition strategy, but it doesn\'t work for me.

const scrollStrategy = this.overlay.scrollStrategies.reposition();
con         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 02:59

    I was looking for a similar solution as OP. The trick in the provided example is to set overflow:auto on the .cdk-global-overlay-wrapper.

    Add this css to your styles (not inside the dialog's css):

    .cdk-global-overlay-wrapper {
      overflow: auto;
    }
    

    If you want to prevent scrolling on the back scenery i.e. parent component you could set overflow: hidden on the parent as long as the dialog is open.

    .. just remove the scroll strategy from the example.

提交回复
热议问题