Last active
March 24, 2017 11:01
-
-
Save ZoolWay/8204ba8ba4b1e37baa84eed0dcc5457f to your computer and use it in GitHub Desktop.
add/remove
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="my-comp"></require> | |
<h1>Custom Component with boolean attribute binding</h1> | |
<h2>Using a string attribute:</h2> | |
<div> | |
<my-comp value="true"></my-comp> | |
<my-comp value="false"></my-comp> | |
</div> | |
<h2>Using a binding to an expression</h2> | |
<div> | |
<my-comp value.one-time="true"></my-comp> | |
<my-comp value.one-time="false"></my-comp> | |
</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 { bindable, observable } from 'aurelia-framework' | |
export class App { | |
message = 'Hello World'; | |
@observable | |
buttons = []; | |
getNewEntry(){ | |
let s = 'entry #' + Math.floor((Math.random() * 1000) + 1); | |
return s; | |
} | |
add() { | |
console.log('ADD'); | |
this.buttons.push(this.getNewEntry()); | |
console.log('ADDED'); | |
} | |
prepend() { | |
this.buttons.splice(0, 0, this.getNewEntry()) | |
} | |
removeFromTwo() { | |
console.log('REMOVE'); | |
this.buttons.splice(2, 1); | |
//this.isButton4Enabled = !this.isButton4Enabled; | |
console.log('REMOVED'); | |
} | |
} |
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://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['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 style="border:1px dashed blue; margin: 1em;"> | |
<span>Bound to value '${value}' which is of type '${valueType}', comparing to boolean-true evaluates to '${value == true}' or with 3= '${value === true}'</span> | |
</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 { bindable } from 'aurelia-framework' | |
export class MyComp { | |
@bindable | |
value = null; | |
valueType = 'undetected'; | |
valueChanged(newValue, oldValue) { | |
console.debug('value changed from', oldValue, 'to', newValue); | |
this.valueType = typeof(newValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment