Created
April 10, 2015 01:28
-
-
Save TKTheTechie/978a8c0951eefd948495 to your computer and use it in GitHub Desktop.
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='./time-graph'></require> | |
This is my time control! | |
<section time-graph="dailyTraffic.bind:dailyTraffic"></section> | |
</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,customElement} from 'aurelia-framework'; | |
@customElement('time-control') | |
export class TimeControl{ | |
attached(){ | |
this.setDailyTraffic(); | |
} | |
setDailyTraffic(){ | |
this.dailyTraffic='Daily traffic initialized'; | |
} | |
} | |
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 {noView,bindable,customAttribute,inject} from 'aurelia-framework'; | |
@noView | |
@customAttribute('time-graph') | |
@bindable('dailyTraffic') | |
export class TimeGraph{ | |
dailyTrafficChanged(newTraffic){ | |
alert('My traffic has changed:' + newTraffic); //never called | |
} | |
} |
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> | |
<section> | |
<h2>${heading}</h2> | |
<require from='./time-control'></require> | |
<time-control></time-control> | |
<form role="form" submit.delegate="welcome()"> | |
<div class="form-group"> | |
<label for="fn">First Name</label> | |
<input type="text" value.bind="firstName" class="form-control" id="fn" placeholder="first name"> | |
</div> | |
<div class="form-group"> | |
<label for="ln">Last Name</label> | |
<input type="text" value.bind="lastName" class="form-control" id="ln" placeholder="last name"> | |
</div> | |
<div class="form-group"> | |
<label>Full Name</label> | |
<p class="help-block">${fullName | upper}</p> | |
</div> | |
<button type="submit" class="btn btn-default">Submit</button> | |
</form> | |
</section> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two problems, one is yours and one is mine.
My problem is that we incorrectly identify options attributes if you have only one option. I have fixed that and will push the change and release shortly.
The problem in your code relates to how the binding is set up. Here's the correct html:
Notice that you need to use the attribute name in HTML (derived from the property name).