請,我不知道如何正確配置ng-show。需要ng-show驗證輸入,submitt並在提交後不再顯示消息
這是怎麼回事,是這樣的:
1-我有4個輸入,好的。那些正在驗證。 2-我提交,確定。 3將它保存在我的數據庫中之後,清理這些字段,但是顯示所需字段的消息而未提交。我只需要顯示用戶是否提交併且沒有文字。
這裏去我的html:
<div class="grid-form">
<div class="grid-form1">
<h3 id="forms-example" class="">Cadastro de Peças</h3>
<form name="formCadastroPecas" id="formCadastroPecas" role="form" novalidate>
<div class="form-group">
<label for="labelNome">Nome da Peça:</label>
<br>
<select size="3" style="width: 300px" multiple="" class="form-control1" ng-model="nome" ng-options="foo as foo for foo in names">
</select>
</div>
<div class="form-group">
<label for="fabricante">Fabricante:</label> <input
type="text" class="form-control" id="fabricante" ng-model="fabricante" name="fabricante" required>
<span style="color: red"
ng-show="submitted && formCadastroPecas.fabricante.$error.required" >Campo
Fabricante Obrigatório.</span>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Modelo:</label> <input
type="text" class="form-control" id="modelo" ng-model="modelo" name="modelo" required>
<span style="color: red"
ng-show="submitted && formCadastroPecas.modelo.$error.required" >Campo
Modelo Obrigatório.</span>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Preço de Compra:</label> <input
type="text" class="form-control" id="precoCompra" ng-model="precoCompra" name="precoCompra" required>
<span style="color: red"
ng-show="submitted && formCadastroPecas.precoCompra.$error.required" >Campo
Peço de Compra Obrigatório.</span>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Preço de Venda:</label> <input
type="text" class="form-control" id="precoVenda" ng-model="precoVenda" name="precoVenda" required>
<span style="color: red"
ng-show="submitted && formCadastroPecas.precoVenda.$error.required" >Campo
Preço de Venda Obrigatório.</span>
</div>
<button type="submit" class="btn btn-lg btn-danger" ng-disabled="form.$invalid" ng-click="submitForm(formCadastroPecas)">Cadastrar</button>
<br>
<span align="left" id="retornoValidacao" style="color: red">{{retorno.data.message}}</span>
<div class="alert alert-success" ng-show="show" role="alert">
<center>
<strong>OK!</strong> Peça cadastrada com sucesso.
</center>
</div>
</form>
您是否需要將清除的窗體上的驗證消息隱藏起來? –