Skip to content

Instantly share code, notes, and snippets.

@davismj
Forked from bigopon/app.html
Last active November 29, 2017 04:18
Show Gist options
  • Save davismj/999bb027ea9779ab0c50da920783a307 to your computer and use it in GitHub Desktop.
Save davismj/999bb027ea9779ab0c50da920783a307 to your computer and use it in GitHub Desktop.
Respond to changed values demo
<template>
<input type="number" value.bind="value" change.delegate="updateValue(value)" />
</template>
import { observable } from 'aurelia-framework';
export class AppViewModel {
@observable value = 1;
// Triggered when value changes, enabled by decorating value with @observable.
valueChanged(newValue, oldValue) {
console.log('valueChanged', newValue, oldValue)
}
// Triggered when the value in the input elementchanges, enabled by adding a
// change.delegate handler in the view.
updateValue(value) {
console.log('change.delegate', value);
}
}
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment