Last active
December 13, 2016 03:49
-
-
Save plwalters/6928d1242621c7b6b6e5f6cab89e4710 to your computer and use it in GitHub Desktop.
DI inheritance
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> | |
<require from="./sample"></require> | |
<h1>Dialog Repro</h1> | |
<sample></sample> | |
</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 {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); | |
}); | |
} | |
} |
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> | |
<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> |
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
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-dialog'); | |
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 { DialogController } from 'aurelia-dialog'; | |
export class ModalController { | |
static inject = [DialogController]; | |
constructor(dialogController) { | |
this.dialogController = dialogController; | |
this.settings = dialogController.settings; | |
} | |
ok(model) { | |
return this.dialogController.ok(model); | |
} | |
cancel(model) { | |
return this.dialogController.cancel(model); | |
} | |
} |
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 { DialogService } from 'aurelia-dialog'; | |
export class ModalService { | |
static inject = [DialogService]; | |
constructor(dialogService) { | |
this.dialogService = dialogService; | |
} | |
open(modalModel) { | |
return this.dialogService.open(modalModel); | |
} | |
} |
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> | |
<ai-dialog> | |
<ai-dialog-body> | |
<h2>Edit name</h2> | |
<input value.bind="person.name" /> | |
</ai-dialog-body> | |
<ai-dialog-footer> | |
<button click.trigger="cancelButtonClick()">Cancel</button> | |
<button click.trigger="ok(person)">Ok</button> | |
</ai-dialog-footer> | |
</ai-dialog> | |
</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 {ModalController} from './modal-controller'; | |
export class Prompt { | |
static inject = [ModalController]; | |
constructor(modalController) { | |
this.modalController = modalController; | |
} | |
save() { | |
this.modalController.ok(result); | |
} | |
cancelButtonClick() { | |
this.modalController.cancel(); | |
} | |
} |
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> | |
<h1>Test</h1> | |
<button click.trigger="createProjectButtonClick()">Open</button> | |
</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 {ModalService} from './modal-service'; | |
export class Sample { | |
accountId = 1; | |
static inject = [ModalService]; | |
constructor(modalService) { | |
this.modalService = modalService; | |
} | |
createProjectButtonClick() { | |
this.modalService.open({ | |
viewModel: './prompt', | |
model: { accountId: this.accountId }, | |
}).then(result => { | |
if(result.wasCancelled) { | |
return; | |
} | |
console.log(result); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment