3.3 Select component
Last updated
Last updated
Citation from
In Aurelia, user interface components are composed of view and view-model pairs. The view is written with HTML and is rendered into the DOM. The view-model is written with ES 2016 and provides data and behavior to the view. The Templating Engine along with Dependency Injection are responsible for creating these pairs and enforcing a predictable lifecycle for the component. Once instantiated, Aurelia's powerful databinding links the two pieces together allowing changes in your view-model to be reflected in the view and changes in your view to reflected in your view-model. This Separation of Concerns is great for developer/designer collaboration, maintainability, architectural flexibility, and even source control.
To create a UI component, you need only create two files, one for each of the component parts.
where the single statement <select md-select="selected.two-way: selectedMeal;">
is responsible for the instantiation of the select control:
Image 1
Observe that the custom atttribute defined on this single statement (selected
) coupled with the use of Aurelia .bind
feature maps the value of the selected
attribute with the variableselectedMeal
defined in the matching view model (shown below)
Finally, add the new component to your router-configuration:
app.js