Skip to content

Instantly share code, notes, and snippets.

@Thanood
Created December 4, 2016 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Thanood/db1c3aeb0495f47c9c0afbd5dbbd8b58 to your computer and use it in GitHub Desktop.
Save Thanood/db1c3aeb0495f47c9c0afbd5dbbd8b58 to your computer and use it in GitHub Desktop.
Aurelia-Materialize bridge select valueConverter
<template>
<require from="./filterPizzaValueConverter"></require>
<div>
<md-checkbox md-checked.bind="shouldFilter"></md-checkbox>
<select md-select value.two-way="selectedMeal">
<option disabled>Select your meal</option>
<option repeat.for="meal of food | filterPizza:shouldFilter" model.bind="meal">${meal.name}</option>
</select>
<a md-button="flat: true;" md-waves click.trigger="setSelectedMeal()" class="accent-text">select steak</a>
You selected: ${selectedMeal.name}
</div>
</template>
export class BasicUse {
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];
setSelectedMeal() {
this.selectedMeal = this.food[2];
}
}
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