Empty the form & setPristine
The $setPristine
was not working as intended because the $scope.talk = {}
was discovered by angular after it was called. Thus the form was modified after & marked dirty. At least I believe this is what happened. One way to do this is to call $setPristine
after the digest. It could be achieved using $watch
.
I propose to try something like :
// We do not try deep inspection on talk to not be informed of changes
// of attributes' values
$scope.$watch('talk', function(talk) {
// If the talk object is not empty, do nothing
if (talk) return;
// Set form as pristine
$scope.form.$setPristine();
});