Skip to content

Instantly share code, notes, and snippets.

@ndtuan412
Last active June 9, 2016 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndtuan412/57c5458cd051535a4cf60e1134e45087 to your computer and use it in GitHub Desktop.
Save ndtuan412/57c5458cd051535a4cf60e1134e45087 to your computer and use it in GitHub Desktop.
<template>
<div class="contact box">
<h3>Contact</h3>
<div class="form-box form-horizontal">
<div class=" form-inline">
<label for="phone">Phone</label>
<input type="phone" class="form-control" name="phone" placeholder="Phone" value.two-way="phone">
</div>
</div>
</div>
</template>
import {bindable} from 'aurelia-framework';
export class ContactCustomElement {
@bindable phone;
};
import {bindable, processContent, noView, customElement} from 'aurelia-framework'
@processContent(function(viewCompiler, viewResources, element, instruction) {
instruction.viewFactory = viewCompiler.compile('<template>' + element.innerHTML + '</template>', viewResources, instruction);
element.innerHTML = '';
return false;
})
@noView
export class CreateLocationCustomElement {
@bindable myContact;
save() {
alert(this.myContact.phone);
}
}
<!doctype html>
<html>
<head>
<title>Create Location</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<create-location my-contact.two-way="vm">
<contact title="Contact" phone="01234" view-model.ref="vm"></contact>
<button type="button" click.delegate="save()">Save</button>
</create-location>
<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>
export function configure(aurelia) {
aurelia.use
.defaultBindingLanguage()
.defaultResources()
.developmentLogging()
.globalResources(["create-location", "contact"]);
aurelia.start().then(a => {
a.enhance(document.body);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment