lundi 21 mars 2016

Angular: multiple ng-if problems

I validate an emailaddress in my controller. When there is an error, I would like to show a error-message...

In this scenario, the user types in: myname@email (invalid)

The validation is working fine and my scope is as following:

Object {
    email_used: false,
    email_invalid: true,
    email_required: false
}

In my template, the error class on the input field works correctly:

<input type="email" name="email" placeholder="E-mailadres" ng-model="new_user.email" class="grid-100" ng-class="(error_register.email_used || error_register.email_invalid || error_register.email_required) ? 'error' : ''"/>

... but my error message is not shown?

<!-- ERRORS -->
<span class="ngdialog-form-error" ng-if="error_register.email_used" ng-cloak>Email is used<span>
<span class="ngdialog-form-error" ng-if="error_register.email_required" ng-cloak>Email required<span>
<span class="ngdialog-form-error" ng-if="error_register.email_invalid" ng-cloak>Email invalid<span>
<!-- / ERRORS -->

(I'm using Angular 1.2.0)

Aucun commentaire:

Enregistrer un commentaire