是什么原因?为什么ng-message总是显示? 包括angularjs / 1.2.7 / angular.js.控制台中没有错误。
<body>
<form name="myForm">
<label>
Enter your name:
<input type="text"
name="myName"
ng-model="name"
ng-minlength="5"
ng-maxlength="20"
required />
</label>
<div ng-messages="myForm.myName.$error" style="color:maroon" role="alert">
<div ng-message="required">You did not enter a field</div>
<div ng-message="minlength">Your field is too short</div>
<div ng-message="maxlength">Your field is too long</div>
</div>
</form>
<script>
(function () {
myForm.myName.$error = {
}})
</script>
</body>
</html>