Pushed an update with an ES5 traversal. Here is the result from babel: 'use strict';
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } //es5 helper function Es5TraverseAndFindFocusableElements(elm) { var result = []; inspect(elm); return result; function inspect(elm) { if (elm.tabIndex > -1) { result.push(elm); } var _arr = [].concat(_toConsumableArray(elm.children)); for (var _i = 0; _i < _arr.length; _i++) { var child = _arr[_i]; inspect(child); } } } function focusNext() { return { restrict: "A", //make it an attribute selector controller: focusNextController }; /* ngInject() */ function focusNextController($element) { var el = $element[0]; //grab the raw dom element! this.$onInit = function () { el.addEventListener('keydown', handleEnter); }; this.$onDestroy = function () { el.removeEventListener('keydown', handleEnter); }; function handleEnter(ev) { if (ev.keyCode === 13) { ev.preventDefault(); // utilize the above generator and ES6 spread to build an array of focusable elements // now using an ES5 helper. var elmList = Es5TraverseAndFindFocusableElements(document. body); var current = elmList.findIndex(function (n) { return n == el; }); var next = Math.min(elmList.length - 1, current + 1); if (ev.shiftKey) { //reverse on shift, make it on par with tab. next = Math.max(0, current - 1); } elmList[next].focus(); } } } } angular .module('nextEnter', []) .directive('focusNext', focusNext); Hope this helps you. -- You received this message because you are subscribed to the Google Groups "Angular" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.