Search code examples
angularantdng-zorro-antd

ng-zorro NzDrawerService nzOffsetX dynamically


I dynamically create a component inside a drawer using the NzDrawerService. The issue is that need to set nzOffsetX after an event is passed, which I cannot do with this API.

https://ng.ant.design/components/drawer/en#components-drawenr-demo-service

Can anyone help me? I am stuck for a long time here. Thanks


Solution

  • You can modify the properties of NzDrawerRef.

    openDrawer(): void {
      this.drawerRef = this.drawerService.create({
        ...
      });
    
      setTimeout(() => {
        (this.drawerRef as any).nzOffsetX = 100;
      }, 2000)
    }