Skip to content

Instantly share code, notes, and snippets.

@sjarvela
Last active October 31, 2021 14:11
Show Gist options
  • Save sjarvela/493140737f85dc02f8d62e73ce78a76a to your computer and use it in GitHub Desktop.
Save sjarvela/493140737f85dc02f8d62e73ce78a76a to your computer and use it in GitHub Desktop.
aurelia2-custom-elements
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber Gist uses dumber bundler, the default bundle file
is /dist/entry-bundle.js.
The starting module is pointed to "main" (data-main attribute on script)
which is your src/main.js.
-->
<body>
<my-app></my-app>
<script src="/dist/entry-bundle.js" data-main="main"></script>
</body>
</html>
{
"dependencies": {
"aurelia": "latest"
}
}
<div style="color: red; border: 1px solid red">This is custom element A</div>
export class CustomElementA {
}
<import from="./custom-element-a"></import>
<div style="border: 1px solid blue">
<div style="color: blue">This is custom element B</div>
<span>And here is custom element A inside B:</span>
<custom-element-a></custom-element-a>
</div>
export class CustomElementB {
}
import Aurelia from 'aurelia';
import { MyApp } from './my-app';
Aurelia.app(MyApp).start();
<import from="./custom-element-a"></import>
<import from="./custom-element-b"></import>
<h1>Custom elements</h1>
<h2>Custom element A directly under app</h2>
<custom-element-a></custom-element-a>
<h2>Custom element A inside custom element B</h2>
<custom-element-b></custom-element-b>
export class MyApp {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment