Reputation: 681
I want to validate a form and show error message corresponding to a validation code.
Following is my current code
<div class="alert alert-danger" ng-show="Ctrl.getValidationCode()=== Ctrl.VALIDATION_CODE['EXCEEDED_RANGE'] ">fromdate exceeded todate</div>
Is it better to use this
ng-show="Ctrl.getValidationCode()=== Ctrl.VALIDATION_CODE['EXCEEDED_RANGE']"
Or use this instead
ng-show="Ctrl.getValidationCode()=== 1"
I think the first one is better Because It's cleaner to the second one. But the first one is too long.
Could you give me your opinions and advice?
Upvotes: -1
Views: 185
Reputation: 19
I think that the best way is a new directive that handle all form erros messages in your application.
Upvotes: 1
Reputation: 323
First one is more practical, because you can give your code some freedom. So if you use that validation code on few pages, it's lot easier to manage that code. Because if you need to change code, you will change it only on one place instead of going to separate pages. It's something like convention.
Upvotes: 1