Angular Material: Popup Windows : Allow Windows to Go Between Front and Back

后端 未结 1 1440
一生所求
一生所求 2020-12-22 15:06

We have 1) Material Dialog Component Opening up 2) Another Material Dialog Component, when user press "Open Adv. Search" Button.

The first Dialog component

相关标签:
1条回答
  • 2020-12-22 15:46

    This is an aproximate response, but perhafs can inspirated you

    You can assing one "id" different for each MatDialog (and pass as element of the data)

    const dialogRef = this.dialog.open(YourComponentDialog, {
          width: '250px',
          data: {data: test, id:'child'}, //<--this
          disableClose:true,
          hasBackdrop:false,
          id:'child' //<--this 
    
        });
    

    If in constructor of the components you inject OverlayContainer

    constructor(public cdk:OverlayContainer,...){}
    

    You can create a function toTop that receive the "id"

      toTop(id)
      {
        this.cdk.getContainerElement().childNodes.forEach((x:any)=>{
          if (x.innerHTML.indexOf('id="'+id+'"')<=0)
            x.style["z-index"]=1000;
          else
            x.style["z-index"]=1001;
        })
      }
    

    Just simply call to the function in (click) -you can call the funciton only if you click the title or in several places.

    a stackblitz

    NOTE: store in a variable if the parent open the child. so before open the child, check the variable and if is open simply send it to top

    0 讨论(0)
提交回复
热议问题