Created
April 1, 2016 09:54
-
-
Save Thanood/17e777c2122c70d06585fa773bd5917e to your computer and use it in GitHub Desktop.
Aurelia - select
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> | |
<select class="form-control" value.bind="selectedValue"> | |
<option>Select value</option> | |
<option repeat.for="value of values" model.bind="value">${value.Name} </option> | |
</select> | |
</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 {inject, bindable} from 'aurelia-framework'; | |
import {BindingEngine} from 'aurelia-binding'; | |
@inject(BindingEngine) | |
export class App { | |
constructor(bindingEngine) { | |
this.values = [{ Id: 2, Name: 'A', Email: 'B' }, { Id: 3, Name: 'B', Email: 'B' }]; | |
this.selectedValue = { Id: 1, Name: 'default', Email: 'default' }; | |
this.valuesubscription = bindingEngine.propertyObserver(this, 'selectedValue') | |
.subscribe(this.selectedValueChanged); | |
} | |
selectedValueChanged(){ | |
console.log('selected value changed'); | |
} | |
} |
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> | |
<link rel="stylesheet" href="styles.css"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/config2.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
/******************************************************************************* | |
* The following two lines enable async/await without using babel's | |
* "runtime" transformer. Uncomment the lines if you intend to use async/await. | |
* | |
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2 | |
*/ | |
//import regeneratorRuntime from 'babel-runtime/regenerator'; | |
//window.regeneratorRuntime = regeneratorRuntime; | |
/******************************************************************************/ | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging(); | |
aurelia.start().then(a => a.setRoot()); | |
} |
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 { inject } from 'aurelia-framework'; | |
@inject(Element) | |
export class MyAttributeCustomAttribute { | |
constructor(element) { | |
this.element = element; | |
} | |
attached() { | |
window.setTimeout(() => { | |
this.element.au['my-element'].viewModel.foo = 'changed'; | |
}, 2000); | |
} | |
} |
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> | |
<input type="text" value.bind="foo" /> | |
</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} from 'aurelia-framework'; | |
export class MyElement { | |
@bindable() foo = '5'; | |
} |
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
/* Styles go here */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment