Focus on the first field that is .ng-invalid at Submit - not working for radios-inline
问题 I am using the directive from accepted answer on Set focus on first invalid input in AngularJs form to accomplish this: app.directive('accessibleForm', function () { return { restrict: 'A', link: function (scope, elem) { // set up event handler on the form element elem.on('submit', function () { console.log("inside focus directive"); // find the first invalid element var firstInvalid = elem[0].querySelector('.ng-invalid'); //if we find one, set focus if (firstInvalid) { firstInvalid.focus();