Last active
October 11, 2016 14:27
-
-
Save funky-jojo/22d186d866ac08bd4a198131cc5b4913 to your computer and use it in GitHub Desktop.
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> | |
<require from="list"></require> | |
<list items.bind="list"></list> | |
</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 { | |
list = [{val:"Fred"}, {val:"John"}, {val:"Jane"}]; | |
} |
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://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> |
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> | |
<div class="input-group" repeat.for="item of items"> | |
<input value.bind="item.val" class="input" type="text" placeholder="Item"> | |
<a href="javascript:void" click.delegate="deleteItem(item)">Delete</a> | |
<a href="javascript:void" click.delegate="moveItemUp(item)">Up</a> | |
<a href="javascript:void" click.delegate="moveItemDown(item)">Down</a> | |
</div> | |
<a href="javascript:void" click.delegate="addItem()">Add Item</a> | |
<a href="javascript:void" click.delegate="checkValues()">Check Values</a> |
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, bindingMode} from "aurelia-framework"; | |
export class List { | |
@bindable({defaultBindingMode: bindingMode.twoWay}) items; | |
constructor() {} | |
addItem() { | |
this.items.push('new') | |
} | |
deleteItem(item) { | |
let i = this.items.indexOf(item) | |
this.items.splice(i, 1) | |
} | |
moveItemUp(item) { | |
let i = this.items.indexOf(item) | |
if (i === 0) return | |
let temp = item | |
this.items.splice(i, 1) | |
this.items.splice(i - 1, 0, temp) | |
} | |
moveItemDown(item) { | |
let i = this.items.indexOf(item) | |
if (i === this.items.length) return | |
let temp = item | |
this.items.splice(i, 1) | |
this.items.splice(i+1, 0, temp) | |
} | |
checkValues(){ | |
alert(JSON.stringify(this.items)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment