1
I have the following directive:
//diretiva responsavel por facilitar a passagem de campos para a validação
App.directive("validateMsgFor", function(){
return{
templateUrl : "view/templates/validateMsgFor.html",
restrict: "E",
scope: {
field : "="
}
}
});
And the template she uses is as follows::
<div ng-if="field.$dirty" ng-messages="field.$error">
<div ng-messages-include="view/messages.html"></div>
</div>
which in turn uses the following html:
<div class="messages">
<div ng-message="required">Campo Obrigatório</div>
<div ng-message="minlength">Necessário mais caracteres</div>
<div ng-message="maxlength">Necessário menos caracteres</div>
<div ng-message="email">E-mail inválido</div>
<div ng-message="compareTo">Deve corresponder com valor digitado anteriormente</div>
</div>
All this to be used as follows:
<label>Departamento</label>
<select id="departamentos" ng-model="model.curso.departamento" name="departamento" ng-options="d.nome for d in departamentos track by d.id" ng-required="true">
<option value="">Selecione um Departamento</option>
</select>
<validate-msg-for field="mainForm.departamento"></validate-msg-for>
This works the way I expect, which is to show the message when there is a validation error and when the field is in "Dirty" status. However, when I click on another link, that is, when I go to another page, the tab freezes, starts to use the processor a lot, indicating some kind of infinite loop or something, and then the page breaks. I realized that this only happens when the message is appearing, and when I comment the tag , does not happen the problem.
My question is knowing what I’m doing wrong, isn’t that the way I’m supposed to wear it? And if anyone has any suggestions?
Versions of angular, angular-route and messages are 1.4.3. Thanks in advance.