Skip to content

Instantly share code, notes, and snippets.

@deap82
Forked from fabioluz/app.html
Last active August 24, 2017 13:04
Show Gist options
  • Save deap82/303efec9b4d08191b083e6eeddc0cd58 to your computer and use it in GitHub Desktop.
Save deap82/303efec9b4d08191b083e6eeddc0cd58 to your computer and use it in GitHub Desktop.
<template>
<require from="./my-attr-options"></require>
<require from="./my-attr"></require>
<div my-attr my-attr-options="option1.bind: firstInstanceOpt"></div>
<div my-attr my-attr-options="option1.bind: secondInstanceOpt"></div>
<div my-attr></div>
</template>
export class App {
opt1 = 'an option value';
opt2 = 'another option value';
firstInstanceOpt = 'first instance';
secondInstanceOpt = 'second instance';
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</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>
import { bindable } from 'aurelia-framework';
export class MyAttrOptionsCustomAttribute {
@bindable option1;
constructor() {
this.option1 = 'default value';
}
}
import { inject } from 'aurelia-framework';
import { MyAttrOptionsCustomAttribute } from 'my-attr-options';
@inject(MyAttrOptionsCustomAttribute)
export class MyAttrCustomAttribute {
constructor(myAttrOptions) {
this.myAttrOptions = myAttrOptions;
console.log('ctr', this.myAttrOptions.option1);
}
attached() {
console.log('attached', this.myAttrOptions.option1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment