Skip to content

Instantly share code, notes, and snippets.

@Thanood
Forked from eikaramba/app.html
Last active January 9, 2017 19:46
Show Gist options
  • Save Thanood/767feb33eeee670625180aaeac414c98 to your computer and use it in GitHub Desktop.
Save Thanood/767feb33eeee670625180aaeac414c98 to your computer and use it in GitHub Desktop.
Aurelia-Materialize bridge select filtered repeat
<template>
<require from="./filterPizzaValueConverter"></require>
<div style="margin-bottom: 15px;">
Thanks to @eikaramba
</div>
<div>
<md-checkbox md-checked.bind="shouldFilter">filter pizza (changes the array for select)</md-checkbox>
<select md-select multiple md-select.ref="select" value.two-way="selectedMeal">
<option value="" disabled>Select your meal</option>
<option repeat.for="meal of food | filterPizza:shouldFilter" model.bind="meal" value.bind="meal.id">${meal.name}</option>
</select>
<p>
You selected:
</p>
<ul>
<li repeat.for="meal of selectedMeal">${meal.name}</li>
</ul>
</div>
</template>
import {observable} from 'aurelia-framework';
export class BasicUse {
@observable() shouldFilter = false;
food = [
{ id: 0, name: 'Pizza' },
{ id: 1, name: 'Cake' },
{ id: 2, name: 'Steak' },
{ id: 3, name: 'Pasta' },
{ id: 4, name: 'Fries' }
];
selectedMeal = [this.food[1]];
shouldFilterChanged() {
this.select.refresh();
}
}
export class FilterPizzaValueConverter {
toView(array,toFilterOrNotToFilter) {
if(array)
return array.filter(r => {
return !toFilterOrNotToFilter || r.name==='Pizza';
});
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-materialize-bundles/0.20.2/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
/*******************************************************************************
* The following two lines enable async/await without using babel's
* "runtime" transformer. Uncomment the lines if you intend to use async/await.
*
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2
*/
//import regeneratorRuntime from 'babel-runtime/regenerator';
//window.regeneratorRuntime = regeneratorRuntime;
/******************************************************************************/
import 'materialize';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-materialize-bridge', bridge => bridge.useAll() );
aurelia.start().then(a => a.setRoot());
}
<template>
This is page 1.
</template>
export class Page1 { }
<template>
This is page 2.
</template>
export class Page2 { }
Usage explanation

The <md-breadcrumbs> custom element reads the top level router and displays a breadcrumb for each route fragment. Credits due to heruan's solution. This Materialize implementation is basically a copy of his work, adjusted to Materialize.


For simple manually-controlled breadcrumbs, use the classes provided by Materialize:

<nav>
  <div class="nav-wrapper">
    <div class="col s12">
      <a href="#!" class="breadcrumb">First</a>
      <a href="#!" class="breadcrumb">Second</a>
      <a href="#!" class="breadcrumb">Third</a>
    </div>
  </div>
</nav>

You can add the primary class to <nav> to match your chosen primary color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment