Skip to content

Instantly share code, notes, and snippets.

@mattduffield
Last active October 10, 2016 17:39
Show Gist options
  • Select an option

  • Save mattduffield/d1a17e87a43eaf5f694a886f305eeb8d to your computer and use it in GitHub Desktop.

Select an option

Save mattduffield/d1a17e87a43eaf5f694a886f305eeb8d to your computer and use it in GitHub Desktop.
Aurelia Gist - Custom Element - my-input
<template>
<require from='my-input'></require>
<h1>${title}</h1>
<form>
<my-input label="Customer Name"
placeholder="Enter your name..."
value.two-way="customerName"></my-input>
<p>${customerName}</p>
</form>
</template>
export class App {
title = 'Custom Element - my-input';
customerName;
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.panel {
border: 1px solid black;
}
.panel-heading {
background: lightblue;
color: white;
border-bottom: 1px solid black;
padding: 3px;
font-size: 20px;
}
.panel-body {
padding: 3px;
}
</style>
</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>
<template> <label>${label}</label> <input type.bind="type" placeholder.bind="placeholder" value.bind="value"> </template>
import {customElement, bindable} from 'aurelia-framework';
@customElement('my-input')
export class MyInput {
@bindable type = 'text';
@bindable label = '';
@bindable placeholder = '';
@bindable value;
constructor() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment