How can I position a dialog above the triggering button?

后端 未结 4 444
悲哀的现实
悲哀的现实 2020-12-14 01:10

I\'m about to put a fist through my PC screen. I have a dialog box that refuses to budge a hot inch above my submit button at the bottom of the screen -- I want it at the v

4条回答
  •  伪装坚强ぢ
    2020-12-14 01:58

    You can adjust position of dialog component using updatePosition() method of MdDialogRef. first import this line in your dialog component

    import { MdDialog, MdDialogConfig, MdDialogRef } from '@angular/material';
    

    in constructor use this

    constructor(public dialModalRef: MdDialogRef) { }
    

    then from inside dialog modal component call this method anywhere you want

     changePosition() {
            this.dialModalRef.updatePosition({ top: '50px', left: '50px' });
        }
    

    read more about it here https://material.angular.io/components/component/dialog

    i hope this will help :)

提交回复
热议问题