Value converters

As we explained before coming across this topic, user interface elements in Aurelia are composed of two files: view and view model pairs. The view is written in pure HTML and is rendered into the DOM. The view model is written in JavaScript and provides data and behavior to the view. Aurelia links the two files together, as one single element using its powerful data binding engine, allowing changes in your view model to be reflected in the view and vice versa. Sometimes the data showed by your view model is not in a good or understandable format for displaying in the UI. Dealing with date and numeric values are the most common scenarios:

export class Example {    constructor() {    this.showRawData();  }  showRawData() {    this.

Get Hands-On Full Stack Web Development with Aurelia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.