Skip to content

Instantly share code, notes, and snippets.

@tkhyn
Last active July 23, 2017 03:28
Show Gist options
  • Save tkhyn/6959cfa7bb1ee3f382d889bf864c5fb1 to your computer and use it in GitHub Desktop.
Save tkhyn/6959cfa7bb1ee3f382d889bf864c5fb1 to your computer and use it in GitHub Desktop.
Aurelia custom attribute demo
<template>
<require from="datepicker"></require>
<h1>${text}</h1>
<p>Enter your name: <input type="text" value.bind="name"></p>
<p>Enter the date: <input type="text" datepicker value.bind="date"></p>
</template>
export class App {
name = 'world';
get text() {
return `Hello ${this.name}!`;
}
}
import {inject} from 'aurelia-framework';
import Pikaday from 'https://rawgit.com/dbushell/Pikaday/master/pikaday.js';
import 'https://rawgit.com/dbushell/Pikaday/master/css/pikaday.css!';
@inject(Element)
export class DatepickerCustomAttribute {
constructor(element) {
this.element = element;
}
attached() {
this.picker = new Pikaday({ field: this.element });
}
}
<!doctype html>
<html>
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment