Last active
March 1, 2017 22:06
-
-
Save valichek/e1243ac2bfad79c7f6ee2dd6b1b68c1f to your computer and use it in GitHub Desktop.
Aurelia Skeleton list list-item implementation
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> | |
<div>List</div> | |
<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 { | |
message = 'hello world'; | |
attached(){ | |
console.log('app = attached'); | |
} | |
} |
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> | |
<span>${item.name}</span> | |
<i click.delegate="removeItem()" class="icon trash" style="cursor:pointer"> - </i> | |
</div> | |
</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
import {inject,bindable, customElement} from 'aurelia-framework'; | |
@customElement("list-item") | |
export class ListItem { | |
@bindable remove; | |
@bindable item; | |
removeItem() { | |
console.log("removeItem"); | |
this.remove({item: this.item, someParam: "Called from ListItem VM"}) | |
} | |
} |
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-item"></require> | |
<div class="list"> | |
<div class="new-item"> | |
<input value.bind="newListItemName" placeholder="New item name"/> <span click.delegate="newItem()" style="cursor:pointer">+</span> | |
</div> | |
<list-item repeat.for="item of listitems" item.bind="item" remove.call="deleteItem(item, someParam)"></list-item> | |
</div> | |
</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
import {inject,bindable, customElement} from 'aurelia-framework'; | |
import {ListItem} from 'list-item'; | |
@customElement("list") | |
export class List{ | |
listitems = []; | |
@bindable newListItemName; | |
newItem(){ | |
console.log('new item: ' + this.newListItemName); | |
if (this.newListItemName){ | |
this.listitems.push({name:this.newListItemName}); | |
} | |
} | |
deleteItem(item, someParam){ | |
var index = this.listitems.indexOf(item); | |
if (index>-1){ | |
this.listitems.splice(index,1) | |
} | |
console.log('delete ' + index, someParam) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment