Skip to content

Instantly share code, notes, and snippets.

@bigopon
Forked from sjarvela/index.html
Created June 2, 2021 06:43
Show Gist options
  • Save bigopon/b0803983cdb504a8d96e2fa9364d5ab6 to your computer and use it in GitHub Desktop.
Save bigopon/b0803983cdb504a8d96e2fa9364d5ab6 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>
import { customElement, bindable } from "aurelia";
import template from "./custom-element-a.html";
@customElement({ name: "custom-element-a", template })
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 should be custom element A:</span>
<custom-element-a></custom-element-a>
<span>(but it is not rendered)</span>
</div>
import { customElement, bindable } from "aurelia";
import template from "./custom-element-b.html";
@customElement({ name: "custom-element-b", template })
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