Last active
September 9, 2021 13:18
-
-
Save sjarvela/fcc5ad30922a91aba364677161f3ce33 to your computer and use it in GitHub Desktop.
aurelia2-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"aurelia": "latest" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Aurelia from 'aurelia'; | |
import { MyApp } from './my-app'; | |
Aurelia.app(MyApp).start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Compose</h2> | |
Select | |
<button repeat.for="item of items" click.trigger="selected = item">${item.name}</button> | |
<div if.bind="selected"> | |
<span>Selected: ${selected.name}</span> | |
<br/> | |
<div style="border: 1px solid red"> | |
<au-compose view-model.bind="selected.component" model.bind="{ name: selected.name }" /> | |
</div> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MyCustomComponent } from "./my-custom-component"; | |
import { MyCustom2Component } from "./my-custom2-component"; | |
export class MyApp { | |
items = [ | |
{ name: 'Item A', component: MyCustomComponent }, | |
{ name: 'Item B', component: MyCustomComponent }, | |
{ name: 'Item C', component: MyCustom2Component } | |
] | |
selected = null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>This is custom component with name: ${name}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bindable } from "aurelia"; | |
export class MyCustomComponent { | |
@bindable | |
name | |
activate(model) { | |
this.name = model.name; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>This is another custom component with name: ${name}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bindable } from "aurelia"; | |
export class MyCustom2Component { | |
@bindable | |
name | |
activate(model) { | |
this.name = model.name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment