mardi 5 janvier 2016

AngularJS $watch not working in if-block

I figured out, that my angular script is working:

$scope.CurrentUser = null;
$scope.DatePicker = new Date();
$scope.$watch('DatePicker', function (newValue, oldValue) {
    if (newValue > new Date())
        $scope.DatePicker = new Date();
}, true);

<div>
    <input data-ng-model="DatePicker" type="date" id="datepicker" />
</div>

but not if I add an if-statment:

<div data-ng-if="!CurrentUser">
    <input data-ng-model="DatePicker" type="date" id="datepicker" />
</div>

Try it: http://ift.tt/1JUKOZM

But I don't understand why. Is there a known issue? Can anybody help?

Aucun commentaire:

Enregistrer un commentaire