Skip to content

Instantly share code, notes, and snippets.

@funky-jojo
Last active February 9, 2017 19:06
Show Gist options
  • Save funky-jojo/9f7a6a30aa079acc8041f8fe2aa25a0a to your computer and use it in GitHub Desktop.
Save funky-jojo/9f7a6a30aa079acc8041f8fe2aa25a0a to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<require from="./toggle-badge"></require>
<toggle-badge text="North Carolina" checked.bind="inboundLanes"></toggle-badge>
<toggle-badge text="South Carolina" checked.bind="inboundLanes"></toggle-badge>
<div>Selected Lanes:</div>
<div repeat.for="lane of inboundLanes">${lane}</div>
<hr/>
<label><input type="checkbox" model.bind="'North Carolina'" checked.bind="outboundLanes">North Carolina</label>
<label><input type="checkbox" model.bind="'South Carolina'" checked.bind="outboundLanes">South Carolina</label>
<div>Selected Outbound Lanes:</div>
<div repeat.for="lane of outboundLanes">${lane}</div>
</template>
export class App {
inboundLanes = [];
outboundLanes = [];
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
.selected button {
color: red;
}
<template class="toggle-badge ${isSelected ? 'selected' : ''}">
<require from="./toggle-badge.css"></require>
<button click.trigger="toggle()"><i class="fa fa-check"></i>${text}</button>
</template>
import { bindable, bindingMode } from 'aurelia-framework';
export class ToggleBadge {
@bindable({ defaultBindingMode: bindingMode.twoWay }) checked: Boolean;
@bindable({ defaultBindingMode: bindingMode.oneWay }) text: String;
isSelected: Boolean;
toggle() {
this.isSelected = (this.checked = !this.checked);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment