我有这个简单的形式:
<form name="assignCtrl.carrierForm">
<md-input-container class="md-block">
<label>Company Name</label>
<input required name="carrierName" ng-model="assignCtrl.searchKeyword">
<div ng-messages="assignCtrl.carrierForm.carrierName.$error">
<div ng-message="required">This field is required.</div>
</div>
</md-input-container>
<md-input-container class="md-block">
<label>Company Email</label>
<input type="email" name="carrierEmail" ng-model="assignCtrl.companyEmail" required
ng-pattern="/^.+@.+\..+$/" minlength="5" maxlength="100"/>
<div ng-messages="assignCtrl.carrierForm.carrierEmail.$error">
<div ng-message="required">Email is required.</div>
<div ng-message-exp="['pattern', 'minlength', 'maxlength']">Please enter a valid email
address.
</div>
</div>
</md-input-container>
<md-button type="submit" ng-disabled="assignCtrl.carrierForm.$invalid" ng-click="assignCtrl.createAndAssign()">Create and Assign
</md-button>
</form>
它没有被验证!ng-messages
根本不出现。
form.$error
也是空的:
{{assignCtrl.carrierForm.$error | json }}
可能是什么原因?