The default validation for the form I have works as expected. But when a user types in a valid email address and a password of three characters minimum, that doesn't mean the login credentials are valid.
So my question is:
How can I set the model email and password to invalid after server-side validation, so the input-fields get the class ng-invalid instead of ng-valid.
My current code
function IndexCtrl( $scope, $http )
{
$scope.form = {};
$scope.submitLogin = function ()
{
$http.post( '/api/auth/login', $scope.form ).success( function( data )
{
if ( !data.success )
{
$scope.form.errors = [ data ];
// here I also want to mark the models 'email' and 'password' as invalid, so they both get the class 'ng-invalid'
}
else
{
$location.path( '/' );
}
});
};
}
data.successbut instead just handle errors in the error callback.