Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
$scope.$watch stopped firing
Message
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01611409
Message ID:
01611412
Vues:
26
>>Hi everybody,
>>
>>This is absolutely weird. I had a working page where I have the following control (I implemented internalization yesterday):
>>
>>
>><div class="col-lg-12">
>>            <div class="form-group row col-lg-12">
>>
>>                <div class="checkbox pull-left">                   
>>                        <input type="checkbox" name="showFinalized" id="showFinalized"
>>                               ng-model="showFinalized" 
>>                               ng-change="search()"
>>                               data-no:dirty-check />@String.Format(Labels.showFinalizedX, Labels.invoices).TrimEnd()                   
>>                </div>
>>            </div>
>>        </div>
>>
>
>What's the data-no attribute do? It doesn't look like it's in the correct format for an HTML attribute (it looks like a JS attribute).

noDirtyCheck is a directive. I add data in front to avoid the warnings from the VS.

The directive code is the following (and it was borrowed from StackOverflow page and works OK):
(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.focus(function () {
                    ctrl.$pristine = false;
                });
            }
        };
    }]);
})();
BTW, I was wrong saying that ng-change is not firing. I had a breakpoint on the wrong line. It does fire but in the code the $scope.showFinalized is always false regardless on what state the checkbox is.
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