material icon indicating copy to clipboard operation
material copied to clipboard

[master] Error messages won't show with form.field.$dirty added to ng-messages.

Open sheaujye opened this issue 11 years ago • 2 comments

The following won't show the error message, the objective is to prevent showing the error message for the first time (on load).

            <md-input-container>
                <label translate>Email Address *</label>
                <input type="email" name="email" ng-model="user.email" placeholder="[email protected]" required autocomplete="off">
                <div ng-messages="loginForm.email.$error && loginForm.email.$dirty">
                    <div ng-message="required">
                        <translate>Email address is required.</translate>
                    </div>
                    <div ng-message="email">
                        <translate>Invalid email address.</translate>
                    </div>
                </div>
            </md-input-container>

sheaujye avatar Jun 02 '15 05:06 sheaujye

I think you can't use both $error and $dirty inside ng-messages. It should evaluate to key/value pair. Please change it to:- <div ng-messages="loginForm.email.$error" ng-if="loginFrom.email.$touched">

PrashantAshok avatar Jun 12 '15 04:06 PrashantAshok

ok thanks, that works for me.

sheaujye avatar Jun 18 '15 06:06 sheaujye