角:操纵事件触发顺序 - 即NG-模糊和放大器; NG-点击? [英] Angular: manipulating event firing order - namely ng-blur & ng-click?
问题描述
我有两个HTML元素:<艾礼富>
和<贝丝>
。元素<艾礼富>
有一个 NG-模糊
属性和元素<贝丝&GT ;
的 NG-点击
属性
如果我在专注于elment <艾礼富>
,然后点击<贝丝>
出现(根据实验)的 NG-模糊
将火第一和 NG-点击
接下来将闪光。
- 将始终是行为?
- 我可以改变这种行为没有任何努力?
- 将始终是行为?
是的,模糊事件总是会首先解雇
- 我可以改变这种行为没有任何努力?
没有你不能改变的行为。但是,你可以手工管理。您可以使用$超时在NG-模糊回调,并检查是否可以通过NG-点击被操纵的变量。
函数ngClick(){
$ scope.clicked = TRUE;
//你的code休息
}功能ngBlur(){
$ scope.clicked = FALSE;
$超时(函数(){//将ngClick功能后,点击执行情况
如果(scope.clicked $){
返回;
} //你的code休息
})
}
下面是一个工作版本:
http://jsfiddle.net/zhfew91j/2/
I have two html elements: <aleph>
and <beth>
. The element <aleph>
has a ng-blur
attribute and the element <beth>
has the ng-click
attribute.
If I am in focus on elment <aleph>
and click on <beth>
it appears (according to experimentation) that the ng-blur
will fire first and ng-click
will fire next.
- Will that always be the behavior?
- Could I change that behavior without any effort?
- Will that always be the behavior?
Yes, the blur event will always be fired first
- Could I change that behavior without any effort?
No you can not change the behavior. However, you can manage it by hand. You can use $timeout in your ng-blur callback, and check for a variable which can be manipulated by ng-click.
function ngClick () {
$scope.clicked = true;
// rest of your code
}
function ngBlur () {
$scope.clicked = false;
$timeout(function () { // will be executed after ngClick function in case of click
if ($scope.clicked) {
return;
}
// rest of your code
})
}
Here is a working version: http://jsfiddle.net/zhfew91j/2/
这篇关于角:操纵事件触发顺序 - 即NG-模糊和放大器; NG-点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!