我在一个对话框上有一些输入字段和一个提交,一个取消按钮。我使用 ng-message 来显示输入是错误的。但是,当我使用 ng-click="$dismiss()" 单击取消以禁用对话框时,会显示 ng-message 并且操作dismiss() 会终止。对我解决案件的一些建议
<form name="accountGroupForm" novalidate>
<div class="form-group"
>
<input id="group-name" class="form-control" name="groupName" placeholder="{{'Group name' | translate}}"
ng-model="accountGroup.name" ng-focus="true"
required>
<div ng-messages="accountGroupForm.groupName.$error" ng-if="accountGroupForm.groupName.$touched">
<div ng-message="required" class="help-block"><span translate>Group name is required</span></div>
</div>
</div>
<div class="wrapper row">
<div class="col-xs-6 text-right p-r-xs">
<button type="submit" class="hvr-grow btn btn-success w-sm"
ng-disabled="accountGroupForm.$invalid"
ng-click="submitAccountGroup()" translate>
Ok
</button>
</div>
<div class="col-xs-6 text-left p-l-xs">
<button class="hvr-grow btn btn-grey-blue w-sm" ng-click="$dismiss()" translate>Cancel
</button>
</div>
</div>
</form>