-
-
Save AshleyGrant/595675c8a92532574c8877c73ce69440 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
<require from="list-two"></require> | |
<div> | |
With Objects | |
<list items.bind="list"></list> | |
</div> | |
<div> | |
With Strings | |
<list-two items.bind="listTwo"></list-two> | |
</div> | |
</div> | |
</template> |
This file contains hidden or 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"}]; | |
listTwo= ['Fred', 'John', 'Jane']; | |
} |
This file contains hidden or 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 hidden or 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" 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 hidden or 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)); | |
} | |
} |
This file contains hidden or 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 hidden or 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 ListTwo { | |
@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