AngularJS ng-model changes with ng-pattern
AngularJS won't trigger a change on an `ng-model` if the input does not match the `ng-pattern`.
HTML
<div ng-app>
<div ng-controller="PatternTestCtrl">
<form name="ngform">
<label for="phone">Pattern /^0?[0-9]{8,8}$/</label><br/>
<input type="text" name="phone" ng-model="phone1" ng-pattern="/^0?[0-9]{8,8}$/" maxlength="9" placeholder="none"/>
</form>
<form name="ngform2">
<label for="phone">Pattern /^[0-9]{8,9}$/</label><br/>
<input type="text" name="phone" ng-model="phone2" ng-pattern="/^[0-9]{8,9}$/" maxlength="9" placeholder="none"/>
</form>
<ul>
</ul>
</div>
</div>
CSS
input.ng-dirty.ng-invalid { color: red }
JavaScript
function PatternTestCtrl($scope) {
$scope.changes = [];
}