Skip to content

Instantly share code, notes, and snippets.

@Vheissu
Forked from AshleyGrant/app.html
Created July 22, 2016 02:00
Show Gist options
  • Save Vheissu/fb4654876015631582f616c734fae65b to your computer and use it in GitHub Desktop.
Save Vheissu/fb4654876015631582f616c734fae65b to your computer and use it in GitHub Desktop.
Amount Value Converter
<template>
<h1>Current amount: ${amount}</h1>
<label>Enter amount:</label>
<input type="text" id="amount" value.bind="amount | prepend & debounce:500">
</template>
export class App {
amount = '';
}
export class PrependValueConverter {
/**
* This is the value being sent back to the view
*
*/
toView(value) {
return `$${value}`;
}
/**
* Validate the user entered value
* and round it to two decimal places
*
*/
fromView(value) {
return parseFloat(value.toString().replace('$', '')).toFixed(2);
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
</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