Skip to content

Instantly share code, notes, and snippets.

@plwalters
Created November 25, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save plwalters/aae79c2b0157b8d54dc0ce15a5a2d2dc to your computer and use it in GitHub Desktop.
Save plwalters/aae79c2b0157b8d54dc0ce15a5a2d2dc to your computer and use it in GitHub Desktop.
DI inheritance
<template>
<h1>Dialog Repro</h1>
<button click.delegate="submit()">Open Dialog</button>
</template>
import {DialogService} from 'aurelia-dialog';
import {Prompt} from './prompt';
export class App {
person = { name: 'Test' };
static inject = [DialogService];
constructor(dialogService) {
this.dialogService = dialogService;
}
submit(){
this.dialogService.open({ viewModel: Prompt, model: this.person}).then(response => {
if (!response.wasCancelled) {
console.log('good');
} else {
console.log('bad');
}
console.log(response.output);
});
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<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-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
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-dialog');
aurelia.start().then(a => a.setRoot());
}
<template>
<ai-dialog>
<ai-dialog-body>
<h2>Edit name</h2>
<input value.bind="person.name" />
</ai-dialog-body>
<ai-dialog-footer>
<button click.trigger="controller.cancel()">Cancel</button>
<button click.trigger="controller.ok(person)">Ok</button>
</ai-dialog-footer>
</ai-dialog>
</template>
import {DialogController} from 'aurelia-dialog';
export class Prompt {
static inject = [DialogController];
constructor(controller){
this.controller = controller;
}
activate(person){
this.person = person;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment