Skip to content

Instantly share code, notes, and snippets.

@jwx
Forked from jasoncarreira/app.html
Last active May 15, 2017 16:05
Show Gist options
  • Save jwx/4c4a775d8b491589be0c4d8d3f9f3258 to your computer and use it in GitHub Desktop.
Save jwx/4c4a775d8b491589be0c4d8d3f9f3258 to your computer and use it in GitHub Desktop.
Custom element value binding
<template>
<div if.bind="!question.alias || !question.alias.length">
<label>Texte des réponses <a click.delegate="addAlias(question)"><i class="fa fa-plus-square-o"></i></a></label>
<span>aucun text</span>
</div>
<div if.bind="question.alias && question.alias.length">
<label>Texte des réponses <a click.delegate="delAlias(question)"><i class="fa fa-trash-o" aria-hidden="true"></i></a></label>
<span repeat.for="alias of question.alias"><input style="text-align:center" value.bind="question.alias[$index]" /></span>
</div>
</template>
export class App {
question = {
values:[]
};
attached() {
setTimeout(() => { this.question['alias'] = [] }, 3000)
setTimeout(() => { this.question.alias.push("added one text")}, 5000)
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
import {Aurelia} from "aurelia-framework";
import environment from "./environment";
import {UIConfig} from "aurelia-ui-framework";
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration();
aurelia.start().then(() => aurelia.setRoot());
}
/* todo: add styles */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment