私が持っているフォームのデフォルトの検証は期待どおりに機能します。ただし、ユーザーが有効な電子メール アドレスと 3 文字以上のパスワードを入力しても、ログイン資格情報が有効であるとは限りません。
だから私の質問は:
サーバー側の検証後にモデルの電子メールとパスワードを無効 に設定するにはどうすればよいですか。これにより、入力フィールドは ng-valid ではなくクラス ng-invalid を取得します。
私の現在のコード
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( '/' );
}
});
};
}