Skip to content

Instantly share code, notes, and snippets.

@len-ro
Last active August 23, 2016 06:06
Show Gist options
  • Save len-ro/295a3a3b31f022fac38de34ba7912bc2 to your computer and use it in GitHub Desktop.
Save len-ro/295a3a3b31f022fac38de34ba7912bc2 to your computer and use it in GitHub Desktop.
Menu: basic usage
<template>
<require from="number-input"></require>
${precision}, ${format}
<number-input value.bind="value" precision.bind="precision"></number-input>
<input type="number" value.two-way="precision"/>
</template>
import {computedFrom} from 'aurelia-framework';
export class BasicUse {
precision = 2;
value = 10000.1234;
@computedFrom('precision')
get format():string {
return "n" + this.precision;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia KendoUI bridge</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.mobile.all.min.css">
<script src="https://kendo.cdn.telerik.com/2016.1.226/js/jszip.min.js"></script>
</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-kendoui-bundles/0.3.5/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-kendoui-bridge', kendo => kendo.pro());
aurelia.start().then(a => a.setRoot());
}
<template>
${precision}
<input type="number"
ak-numerictextbox="k-widget.bind: numericTextBox; k-value.two-way:value; k-read-only.one-way:readonly; k-spinners.one-way:spinners; k-format.one-way:format; k-decimals.bind: decimals; k-step.one-way:step">
</template>
import {bindable, computedFrom} from 'aurelia-framework';
export class NumberInput {
@bindable
value = null;
@bindable
precision = 2;
@bindable
spinners = true;
@bindable
readonly = false;
numericTextBox = null;
precisionChanged(newValue, oldValue){
let step = Math.pow(10, - this.precision);
this.numericTextBox.setOptions({format: 'n' + newValue, decimals: newValue, step: step});
this.numericTextBox.value(this.value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment