Last active
October 12, 2016 02:47
-
-
Save 3cp/1f1ac417087b44ecabbf08d9f6a869d6 to your computer and use it in GitHub Desktop.
valueChanged
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="./line"></require> | |
| <button click.delegate="update()">update</button> | |
| <svg width="100" height="100"> | |
| <line | |
| repeat.for="value of values" | |
| value.bind="value" | |
| label.bind="labels[value]" | |
| ></line> | |
| </svg> | |
| </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 { | |
| bind() { | |
| this.values = [1]; | |
| this.labels = {"1": 'one', "2": 'two'}; | |
| } | |
| update() { | |
| if (this.values[0] === 1) this.values = [2]; | |
| else this.values = [1]; | |
| } | |
| } |
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> | |
| <svg> | |
| <text x="0" y.bind="value * 20">${content}</text> | |
| </svg> | |
| </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
| import {bindable, computedFrom, containerless} from 'aurelia-framework'; | |
| let ID = 1; | |
| @containerless() | |
| export class Line { | |
| @bindable value; | |
| @bindable label; | |
| constructor() { | |
| this.id = ID; | |
| ID += 1; | |
| } | |
| // uncomment bind callback will make initial valueChanged unfired | |
| // bind() {} | |
| valueChanged(newV, oldV) { | |
| console.log('value changed from ' + oldV + ' to ' + newV); | |
| } | |
| labelChanged(newV, oldV) { | |
| console.log('label changed from ' + oldV + ' to ' + newV); | |
| } | |
| @computedFrom('value', 'label') | |
| get content() { | |
| const c = this.value + ' : ' + this.label; | |
| console.log('content: ' + c); | |
| return c; | |
| } | |
| attached() { | |
| console.log('attached #' + this.id + ' value:' + this.value + ' label:' + this.label); | |
| } | |
| detached() { | |
| console.log('detached #' + this.id + ' value:' + this.value + ' label:' + this.label); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment