I'm trying to use ng-blur on a <tr ng-blur="blurFn()">
but it doesn't fire. It fires only on the child <input>
element.
This is not specific to <tr>
or <td>
. According to Angular documentation, ng-blur
reacts to the blur event, which doesn't "bubble". "focusout" event bubbles, but there is no ng-focusout.
Am I missing something or do I need to create a new directive to handle focusout event?
Here's the code snippet and fiddle:
html
<div ng-app="App">
<div ng-controller="Ctrl as ctrl">
<table>
<tr ng-repeat="item in ctrl.items" ng-blur="ctrl.blurFn()">
<td><input ng-model="item.A"/></td>
<td><input ng-model="item.B"/></td>
</tr>
</table>
</div>
</div>
js
angular.module("App", [])
.controller("Ctrl", function(){
this.blurFn = function($event){
console.log($event.target);
};
this.items = [
{A: "111", B: "222"},
{A: "111", B: "222"},
{A: "111", B: "222"},
{A: "111", B: "222"},
{A: "111", B: "222"}
];
});