I would like to adjust display of form items such as a button's enabled/disabled attribute by testing the Angular JS pristine setting.
When a click event fires the form's pristine value is changed as I would expect but when I manipulate the scope variable directly the form's pristine setting is not changed even though a control on the form is bound to that variable.
Please see the following JSfiddle:
http://jsfiddle.net/nicholasporter/2h7wT/3/
I would expect that the altering of the boolean value would cause the forms pristine setting to change when a control is bound to a scope variable. Is there a better way to test this? Is there a better way to adjust buttons or other DOM elements when nothing has changed on the form? Thanks in advance for any pointers. Here is the code in case the JSfiddle isn't working.
<div ng-app ng-controller="MyCtrl">
<form novalidate name="myForm">
{{myBool}}
<input type="checkbox" ng-model="myBool" />
<button ng-click="myBool=!myBool">JS set</button>
<div>Form Pristine:{{myForm.$pristine}}</div>
</form>
</div>
<script>
function MyCtrl($scope){
$scope.myBool = false;
}
</script>