zakton5/ionic-validation-directive

How to handle the server side errors?

Closed this issue · 3 comments

I have a login page. In that page I need to show the server side errors. Like (The email and password you entered don't match.). How can i do this .

<validation-item errors="{ required: 'This field is required', minlength: 'Usernames must have at least 6 characters' }">
  <label class="item item-input">
    <input type="text" name="username" ng-model="formInfo.username" placeholder="Username" min-length="6" required>
  </label>
</validation-item>

In the above code can I set the errors from controller ?

login

This directive's purpose is solely to display the errors that are already on the input. I recommend using something like Angular UI Validate, which supports both synchronous and asynchronous validation. You can put methods in your controller and call them that way. Here is the github page for it.

If that doesn't work for you, please let me know and I can try to work something else out.

I have completed the server side validation by using Angular UI Validate and your directive. It is working fine. Thanks..:)

I'm glad it worked out!