3.5 Slider component

Unlike the previous two controls, Slider is represented (by Aurelia Materialize bridge) as an Aurelia custom element (component) - since slider is not a native HTML element.

View: md-slider.html

<template>
  <h4>Materialize slider demo</h4>
  <div class="container">
    <div class="row">
      <div class="col s8">
        <md-slider>
          <md-slide repeat.for="slide of slides" img.bind="slide.img" caption-align.bind="img.align">
            <h3>${slide.heading}</h3>
            <h5>${slide.subheading}</h5>
          </md-slide>
        </md-slider>
      </div>
    </div>
  </div>
</template>

Here is this view rendered by the application associated with this tutorial.

Image 1

The HTML code in the view is a good demonstration of Aurelia's support for declarative programming - all attributes of the slider are declared there and bound to view model shown next.

View model: md-slider.js

Finally, add the new component to your router-configuration:

File app.js

Last updated