Google News
logo
Aurelia - Interview Questions
How to Displaying Errors in Aurelia?
The controller exposes properties that are useful for creating error UIs using standard Aurelia templating techniques :
 
results : An array of the current ValidateResult instances. These are the results of validating individual rules.

errors : An array of the current ValidateResult instances whose valid property is false.

validating : a boolean that indicates whether the controller is currently executing validation.

Assuming your view-model had a controller property you could add a simple error summary to your form using a repeat :
  <form>
    <ul if.bind="controller.errors">
      <li repeat.for="error of controller.errors">
        ${error.message}
      </li>
    </ul>
    ...
    ...
  </form>
Advertisement