-
-
Save lebolo/e0c84fea991b7bb9e775f4c0202d8edd 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> | |
<require from="./item"></require> | |
<require from="./hideCompletedValueConverter"></require> | |
<ol> | |
<li>Click the first checkbox</li> | |
<li>Notice that isCompleted bindings disagree with each other.</li> | |
<li>Go to item.js and uncomment bind().</li> | |
<li>Click the first checkbox</li> | |
<li>Notice the issue is gone...</li> | |
<li>What is going on?</li> | |
</ol> | |
<item item.bind="item" repeat.for="item of list | hideCompleted"></item> | |
</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 = [ | |
{ | |
isCompleted: false | |
}, | |
{ | |
isCompleted: false | |
} | |
]; | |
toggleCompleted(item) { | |
this.list = this.list.map(_item => { | |
return _item !== item ? _item : { | |
isCompleted: !item.isCompleted | |
} | |
}); | |
} | |
} |
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 HideCompletedValueConverter { | |
toView(arr) { | |
return arr.filter(item => !item.isCompleted); | |
} | |
} | |
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> | |
${item.isCompleted} | |
<input type="checkbox" checked.one-way="item.isCompleted" | |
change.trigger="app.toggleCompleted(item)"> | |
</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 {bindable, inject} from 'aurelia-framework'; | |
import {App} from './app'; | |
@inject(App) | |
export class ItemCustomElement { | |
@bindable item; | |
constructor(app) { | |
this.app = app; | |
} | |
// bind() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment