Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
By-passing $dirty check
Message
 
 
À
01/04/2015 09:58:53
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01609780
Message ID:
01617620
Vues:
19
>Bear in mind that simply setting an inputs $dirty to false (even when there are no other dirty controls) will not cause the form $dirty to be re-evaluated. You may need something like this in your directive after $setPristine():
var dirty = false;
>angular.forEach(scope.theForm, function (value, key) {
>    if (key[0] != '$') {
>        if (value.$dirty) {
>                dirty = true;
>        }
>    }
>});
>if (!dirty) {
>scope.theForm.$setPristine();
>}
This will reset the form if all inputs are pristine.....
>

For this code to work do I need to add
require: ['^form'],
and use scope.form syntax where you used scope.theForm

?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform