JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.angularjs.org/snapshot/angular.js"></script>
<div ng-app="app">
<div ng-controller="formTest">
<h3>Steps to reproduce behavior</h3>
<ul>
<li>Watch the "Debug Model" output below</li>
<li>Type something in the field</li>
<li>Press "Invalidate Field" button</li>
<li>Type something in the field again</li>
</ul>
<form name="myForm">
<input type="text" name="fullName" ng-model="customer.fullName"/>
</form>
<button ng-click="invalidateField()">Invalidate Field</button>
<table>
<tr>
<td>
<h3>Debug Model</h3>
<pre>{{ customer | json }}</pre>
</td>
<td>
<h3>Debug Form</h3>
<pre>{{ myForm | json }}</pre>
</td>
</tr>
</table>
</div>
</div>
CSS
body {
font-family: sans-serif;
}
td {
width: 50%;
vertical-align: top;
}
.ng-invalid {
border-color: red;
}
JavaScript
angular.module('app', []).controller('formTest',
function formTest($scope) {
$scope.customer = {
fullName: ''
};
$scope.invalidateField = function() {
$scope.myForm.fullName.$setValidity('invalid', false);
};
});