angular中扩展集成ngModel.$render不起作用的问题解决

遇到这种情况,可能是因为还有其他的指令在同时覆盖$render,导致自己写的集成扩展又一次被覆盖掉了

比较常见的就是,在Input中,写了一个directive,而这里面自己要覆盖ngModel.$render

我遇到的情况就是input的监听ngModel把我的给覆盖掉了,导致我写的内容无法执行


解决办法就是在指令里面添加priority属性
这个属性是用来排序的

[color=red]也就是在同一个标签内,使用了多个指令,会有先后的compile和link的顺序,这个属性就是用来排序的,默认为0[/color]

官方文档内容如下
priority

When there are multiple directives defined on a single DOM element, sometimes it is necessary to specify the order in which the directives are applied. The priority is used to sort the directives before their compile functions get called. Priority is defined as a number. Directives with greater numerical priority are compiled first. Pre-link functions are also run in priority order, but post-link functions are run in reverse order. The order of directives with the same priority is undefined. The default priority is 0.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值