Skip to content

Instantly share code, notes, and snippets.

@Thanood
Last active April 1, 2016 09:25
Show Gist options
  • Save Thanood/dbd7de10f71162b029d0657ddb226513 to your computer and use it in GitHub Desktop.
Save Thanood/dbd7de10f71162b029d0657ddb226513 to your computer and use it in GitHub Desktop.
Aurelia - attribute im element
<template>
<require from="./my-element"></require>
<require from="./my-attribute"></require>
<my-element my-attribute foo.bind="initial"></my-element>
<!--<paging num="6"></paging>-->
</template>
export class App {
initial = 'initial value';
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<link rel="stylesheet" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
/*******************************************************************************
* The following two lines enable async/await without using babel's
* "runtime" transformer. Uncomment the lines if you intend to use async/await.
*
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2
*/
//import regeneratorRuntime from 'babel-runtime/regenerator';
//window.regeneratorRuntime = regeneratorRuntime;
/******************************************************************************/
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
aurelia.start().then(a => a.setRoot());
}
import { inject } from 'aurelia-framework';
@inject(Element)
export class MyAttributeCustomAttribute {
constructor(element) {
this.element = element;
}
attached() {
window.setTimeout(() => {
this.element.au['my-element'].viewModel.foo = 'changed';
}, 2000);
}
}
<template>
<input type="text" value.bind="foo" />
</template>
import {bindable} from 'aurelia-framework';
export class MyElement {
@bindable() foo = '5';
}
/* Styles go here */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment