angular 可移动弹框

方法一:

html: 添加指令<div kendoWindowContainer></div>

ts: 1、声明 @ViewChild(WindowContainerDirective, {read: ViewContainerRef}) windowContainer: ViewContainerRef;

      2、在constructor 中注入 private windowService: WindowService

      3、引用弹框的方法

top left :限制弹框位置

wind.content.instance.xxxx : 传递参数 / 获取返回值

弹框ts: 1、接收参数

             

            2、在constructor中注入 private window: WindowRef

            3、返回方法只需为全局变量赋值 即可在父组件中通过wind.content.instance.变量名获取

 

在某些情况下可能出现连续点击弹框失效,具体原因不明可能是指令出现冲突,因此更推荐使用方法二

方法二:

html: 添加指令  <ng-container #windowContainer></ng-container>

ts: 1、声明  @ViewChild("windowContainer", { read: ViewContainerRef }) public containerRef: ViewContainerRef;

     2、在constructor 中注入 private windowService: WindowService

     3、引用弹框的方法

          

          红框是与方法一不同的地方,注意变量名和@ViewChild("windowContainer",...的区别

弹框ts:与方法一一致

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值