I'm trying to iterate through all fields that are required and blank in an Angular controller (it's triggered by a certain button being pressed).
I've got this sitting in the controller:
angular.forEach($scope.form.$error.required, function (field) {
//Do some things to these fields
});
The problem is that I get
TypeError: Cannot read property 'required' of undefined
And in Chrome dev tools $scope.form.$error is undefined. I've confirmed that $scope.form is populated as expected.
I think I'm missing something simple, but not sure what it is.