3
I have a user registration page where I have a code field where I would like to validate it according to a condition ($Scope.error) coming from my controller, I already have some alerts but they validate only the form
Controller:
if(status === 406){
$scope.erro = true;
console.log("Erro");
}
This is the snippet of the button, followed by the template that displays the errors:
<label class="item item-input" style="margin-left:10px;margin-right:10px;margin-top:8px"
ng-class="{'has-errors' : usuarioForm.codigo.$invalid, 'no-errors' : usuarioForm.codigo.$valid}">
<input type="text" name="codigo" placeholder="Código" ng-model="usuario.codigo" ng-minlength="3" ng-maxlength="20"
ng-blur="getUsuario(usuario, $event)" required>
</label>
<div class="error-container" ng-show="usuarioForm.codigo.$error" ng-messages="usuarioForm.codigo.$error">
<div ng-messages-include="error-list.html"></div>
</div>
Template:
<script id="error-list.html" type="text/ng-template">
<div class="error" ng-message="required">
<i class="ion-information-circled"></i>
ESSE CAMPO É OBRIGATÓRIO
</div>
<div class="error" ng-message="erro">
<i class="ion-information-circled"></i>
TESTE
</div>
<div class="error" ng-message="minlength">
<i class="ion-information-circled"></i>
Minimum length of this field is 5 characters!
</div>
<div class="error" ng-message="maxlength">
<i class="ion-information-circled"></i>
Maximum length of this field is 20 characters!
</div>
</script>
In short, I want to display a message when the variable $scope.erro
for true.
Page example:
you managed to solve this problem ? how did you do ?
– FernandoPaiva
@Fernandopaiva I got it, I’ll post the solution
– DiegoAugusto