Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
By-passing $dirty check
Message
 
 
À
23/10/2014 12:11:48
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01609780
Message ID:
01617460
Vues:
31
Hi Viv,

Somehow this doesn't seem to work on one page. I am getting a message about Changes.

My directive is
(function () {
    'use strict';

    var app = angular.module('sysMgrApp');

    app.directive('noDirtyCheck', [function () {
        // Interacting with input elements having this directive won't cause the
        // form to be marked dirty.
        // http://stackoverflow.com/questions/17089090/prevent-input-from-setting-form-dirty-angularjs
        return {
            restrict: 'A',
           
            require: 'ngModel',
            link: function (scope, element, attrs, ctrl) {           

                element[0].focus(function () {
                    ctrl.$pristine = false;
                });
            }
        };
    }]);
})();
and the page has this control:
 <div class="col-lg-5 col-lg-offset-1">
                    <input class="form-control" type="text" ng-model="searchTerm" data-no:dirty-check ="true"
                    placeholder="@Labels.search" />
                </div>
when I type something in that control and inspect the element, I can see the ng-dirty class on it.

Do you see why it's not working in that form? The directive does seem to work OK in other forms.
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