Issue
http://jsfiddle.net/x3azn/AbmsG/1/
I only want to show error messages one at a time. I am thinking of doing it with ng switch
which is more code efficient than ng:show
, however the algorithm I have right now does not currently work.
<div class="errorDiv" ng-switch on="true">
<div ng-switch-when="form.LastName.$error.required" style="color: white; background-color: red">required</div>
<div ng-switch-when="form.LastName.$error.len" style="color: white; background-color: red">len</div>
<div ng-switch-when="form.LastName.$error.dallas" style="color: white; background-color: red">dallas</div>
</div>
Solution
You've got the ng-switch
logic backwards. on
holds the expression to evaluate and the when
s hold what to match. You may not want to do it this way, but this shows what I mean:
<div class="errorDiv" ng-switch on="form.LastName.$error.required">
<div ng-switch-when="true" style="color: white; background-color: red">required</div>
</div>
<div class="errorDiv" ng-switch on="form.LastName.$error.len">
<div ng-switch-when="true" style="color: white; background-color: red">len</div>
</div>
<div class="errorDiv" ng-switch on="form.LastName.$error.dallas">
<div ng-switch-when="true" style="color: white; background-color: red">dallas</div>
</div>
Answered By - dnc253
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.