I have been searching for solutions on Stackoverflow regarding how to reset a form, but I am still not able to figure it out. Even though the input was valid, the error message kept showing up. Upon debugging the application, I noticed that the message was receiving inline styles like "opacity: 1; margin-top: 0px;", but I couldn't determine where this styling was coming from.
<md-input-container flex style="margin-top: 0; margin-bottom: 5px">
<label translate>maintenanceMessage.description</label>
<input md-maxlength="40" required name="description" md-no-asterisk
ng-model="maintenanceMessageCtrl.newMaintenanceMessage.description" flex>
<div ng-messages="maintenanceMessageForm.description.$error" ng-if="maintenanceMessageForm.description.$touched">
<div ng-message="required" translate>maintenanceMessage.description.requiredMessage</div>
<div ng-message="md-maxlength" translate>maintenanceMessage.description.maxLengthMessage</div>
</div>
</md-input-container>
When resetting, the following function is executed:
ctrl.resetFormAndHideDialog = function () {
ctrl.newMaintenanceMessage = {};
ctrl.newMaintenanceMessage.expirationDate = new Date();
ctrl.showLastModification = false;
$scope.maintenanceMessageForm.$setUntouched();
$scope.maintenanceMessageForm.$setPristine();
$mdDialog.hide();
};
Do you think there's something I might be missing?
Thank you in advance for any assistance.
Conclusion: It appears that there may be a bug in angular material 1.1.1 causing the ng-message not to be hidden properly.