>>Bear in mind that simply setting an inputs $dirty to false (even when there are no other dirty controls) will not cause the form $dirty to be re-evaluated. You may need something like this in your directive after $setPristine():
var dirty = false;
>>angular.forEach(scope.theForm, function (value, key) {
>> if (key[0] != '$') {
>> if (value.$dirty) {
>> dirty = true;
>> }
>> }
>>});
>>if (!dirty) {
>>scope.theForm.$setPristine();
>>}
This will reset the form if all inputs are pristine.....
>>
>
>For this code to work do I need to add
>
>require: ['^form'],
>
>and use scope.form syntax where you used scope.theForm
>
>?
'theForm' needs to be the name you have given to the angular form containing the inputs - I'm afraid that doesn't make the directive very portable.
Maybe there's a better way of identifying the FormController that doesn't rely on the name......