Angular.js - ng-change nie uruchamia się, gdy ng-pattern jest nieprawidłowy

Używam ng-pattern do sprawdzania poprawności niektórych pól formularza i używam ng-change, aby oglądać i przetwarzać wszelkie zmiany, jednak ng-change (lub $ scope. $ Watch) będzie uruchamiany tylko wtedy, gdy element formularza znajduje się w $ ważny stan! Jestem nowy w kanciastości, więc nie wiem, jak rozwiązać ten problem, chociaż podejrzewam, że nowa dyrektywa jest dobrym rozwiązaniem.

Jak mogę uzyskać, aby ng-change uruchamiał się w obu stanach $ invalid i $ valid form element, przy czym ng-pattern nadal ustawia stany elementów formularza tak jak poprzednio?

HTML:

<div ng-app="test">
  <div ng-controller="controller">
    <form name="form">
        <input type="text" name="textbox" ng-pattern="/^[0-9]+$/" ng-change="change()" ng-model="inputtext"> Changes: {{ changes }}
    </form>

    <br>
    Type in any amount of numbers, and changes should increment.

    <br><br>
    Now enter anything that isn't a number, and changes will stop incrementing. When the form is in the $invalid state, ng-change doesn't fire.

    <br><br>
    Now remove all characters that aren't numbers. It will increment like normal again. When the form is in the $valid state, ng-change will fire.

    <br><br>
    I would like ng-change to fire even when the the form is $invalid.

    <br><br>
        form.$valid: <font color="red">{{ form.$valid }}</font>

  </div>
</div>

Javascript:

angular.module('test', []).controller('controller', function ($scope) {
    $scope.changes = 0;
    $scope.change = function () {
        $scope.changes += 1;
    };
});

Stworzyłem działające JS Fiddle, które pokazuje problem, który mam.

http://jsfiddle.net/JAN3x/1/

Nawiasem mówiąc, ta kanciasta kwestia wydaje się być również istotna:https://github.com/angular/angular.js/issues/1296

questionAnswers(4)

yourAnswerToTheQuestion