Created
March 21, 2018 00:01
-
-
Save Alexander-Taran/056211a0b8306456d26505cdc12c1b50 to your computer and use it in GitHub Desktop.
Aurelia Gist
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
<template> | |
<template if.bind="!editing"> | |
<h2>${items.length} items!</h2> | |
<ul> | |
<li repeat.for="item of items"> | |
${item.name} | |
</li> | |
</ul> | |
<button click.delegate="toggleEditing()">Edit</button> | |
</template> | |
<template else> | |
<h2>${items.length} items!</h2> | |
<ul> | |
<li repeat.for="item of items"> | |
${$index} ${item.name} | |
<input type="text" value.bind="item.name"> | |
</li> | |
</ul> | |
<ul> | |
<li repeat.for="i of items.length"> | |
${$index} ${items[i].name} | |
<input type="text" value.bind="items[i].name"> | |
</li> | |
</ul> | |
<button click.delegate="toggleEditing()">Save</button> | |
</template> | |
</template> |
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
export class App { | |
constructor () { | |
this.items = []; | |
this.editing = false; | |
} | |
// Toggle the edit form | |
toggleEditing () { | |
this.editing = !this.editing; | |
// Also add a new item | |
if (this.editing) { | |
this.items.push({name:"asd"}); // NOTE: This is where things go wrong | |
for(let x of this.items){ | |
console.log(x) | |
} | |
} | |
} | |
} |
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> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment