这是我的表格
我的行为很奇怪。当我的表单加载时这将显示错误'这是必需的'页面只加载没有任何触摸。 当我输入内容时,消息不会消失它只会在那里。
<form name="myForm">
<md-input-container class="md-icon-float md-block">
<label>{{controlObject.controlValue}}</label>
<md-icon md-font-icon="" aria-label="{{controlObject.controlValue}}"></md-icon>
<input type="text" ng-model="controlObject.controlAttribute" name="{{controlObject.controlId}}" ng-required="true">
<div ng-messages="myForm.{{controlObject.controlId}}.$error" layout-align="end end" layout="column">
<div ng-message="required" ng-if="myForm.$pristine">This is required.</div>
</div>
我不知道我在这里做错了什么。请让我知道如何解决。
答案 0 :(得分:0)
您可以在ng-show
或$dirty
$submitted
<div ng-show="myForm.{{controlObject.controlId}}.$dirty" ng-messages="myForm.{{controlObject.controlId}}.$error" layout-align="end end" layout="column">
<div ng-message="required" ng-if="myForm.$pristine">This is required.</div>
</div>