![](/img/trans.png)
[英]Is there any difference between Chrome and Firefox and browsers in how they parse strings?
[英]How to fix angular directives order (difference between Firefox and other browsers)?
我在一个输入字段上使用了角带式时间选择器。 我需要在timepicker hide事件上添加一些操作,因此在timepicker docs之后 ,我创建了一个执行该操作的指令:
.directive('onTimeHide', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.timepicker().on('hide.timepicker', function(e){
// my code
});
}
};
});
它可以在Chrome和Safari上正常运行,但是Firefox存在问题,无法显示/打开时间选择器小部件。 小部件的适当dom元素已添加到代码中,但是功能不起作用。
经过一些调试后,我发现在Firefox中,我的指令“ on-time-hide”在“ bs-timepicker”之前被调用,而在其他浏览器中则相反。
如果有任何解决建议,我将不胜感激。
谢谢
您可以设置priority
键。 在您的情况下:
.directive('onTimeHide', function() {
return {
restrict: 'A',
priority: -1, // for example
link: function(scope, element, attrs) {
element.timepicker().on('hide.timepicker', function(e){
// my code
});
}
};
});
默认情况下为0
但如果要第二次加载,请设置-1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.