Skip to content

Instantly share code, notes, and snippets.

@Thanood
Created April 4, 2016 11:59
Show Gist options
  • Save Thanood/f3261ffbb0b159d12df2c8b6acf6456f to your computer and use it in GitHub Desktop.
Save Thanood/f3261ffbb0b159d12df2c8b6acf6456f to your computer and use it in GitHub Desktop.
Aurelia @observable
<template>
<select value.bind="selectedFeature">
<option value=''>All Features</option>
<option repeat.for="feature of features" model.bind="feature">${feature.Name}</option>
</select>
Selected: ${selectedFeature.Name}, ID=${selectedFeature.id}
</template>
import {observable} from 'aurelia-framework'
export class App {
@observable selectedFeature = {};
features = [
{ id: 1, Name: 'Rob' },
{ id: 2, Name: 'Jason' },
{ id: 3, Name: 'Charlie' }];
selectedFeatureChanged(n,o) {
console.log(`Changed from ${o.Name} to ${n.Name}`);
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
a {
display: block;
}
a:link {
color: black;
text-decoration: none;
}
.collection-item
{
background: lightgray;
}
/* since you set background property on .collection-item, this style must come after .collection-item otherwise it's not applied */
.active {
background: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment