Created
March 23, 2017 13:54
-
-
Save wshayes/5c8c853b66da59549a280cff045144e7 to your computer and use it in GitHub Desktop.
ViewEngineHooks Aurelia example
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
// Here's an example from Rob Eisenberg | |
// filename: resources/data/countries.js | |
import {viewEngineHooks} from 'aurelia-templating'; | |
let countries = [ | |
{ abbreviation: "AF", name: "Afghanistan" }, | |
{ abbreviation: "AL", name: "Albania" }, | |
{ abbreviation: "DZ", name: "Algeria" }, | |
... | |
]; | |
@viewEngineHooks() | |
export class CountryBinder { | |
beforeBind(view) { | |
view.overrideContext.countries = countries; | |
} | |
} | |
// view template filename: account.html | |
<template class="user-detail" bindable="controller"> | |
<require from="resources/data/countries"></require> | |
... | |
<div class="form-group"> | |
<label class="col-sm-2 control-label">Country</label> | |
<div class="col-sm-3"> | |
<select class="form-control"> | |
<option value="" selected="selected">(please select a country)</option> | |
<option repeat.for="country of countries" value.bind="country.abbreviation">${country.name}</option> | |
</select> | |
</div> | |
</div> | |
... | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment