我想弄清楚在处理
ng-blur
事件我试过了
window.document.activeElement
但它总是“身体”。
Html
<body>
<div name="element1" ng-blur="$ctrl.onBlur($event)">element1</div>
<div name="element2" ng-blur="$ctrl.onBlur($event)">element2</div>
</body>
打字稿
public onBlur($event: any): void {
var value = $event.target.attributes["name"].value;
// value is the name of the element where the event is triggered
// but how to get the element to where the focus has gone to?
}
编辑
使用
$timeout
服务
public onBlur($event: any): void {
this.$timeout(() => {
if (this.$window.document.activeElement) {
// do things
}
}, 1);
}