Last active
October 23, 2016 14:20
-
-
Save bcanzanella/fbee5194ad988fa98e46261e7b61dcf9 to your computer and use it in GitHub Desktop.
dialog not re-binding (with others)
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="./bar"></require> | |
<button click.delegate="prompt()">open dialog</button> | |
<br><br> | |
(app [inline]) inner data:<br> | |
<div repeat.for="s of outer.inner">${s.name}</div> | |
<br>from bar component<br> | |
<bar outer.bind="outer"></bar> | |
<br>from compose<br> | |
<compose view-model="./bar" model.bind="outer"></compose> | |
</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'; | |
import {Prompt} from './prompt'; | |
import {DialogService} from 'aurelia-dialog'; | |
import {Tracker} from './tracker'; | |
export class App { | |
@bindable outer; | |
static inject = [DialogService, Tracker]; | |
constructor(dialogService, tracker) { | |
this.dialogService = dialogService; | |
this.tracker = tracker; | |
this.outer = { | |
inner: [{name:'first inner'},{name:'second inner' } ] | |
}; | |
this.tracker.fromApp = this.outer; | |
let me = this; | |
setTimeout(function() { | |
me.outer = JSON.parse('{ "inner":[{"name":"replaced 1"},{"name":"replaced 2"}]}'); | |
// Object.assign(me.outer, JSON.parse('{ "inner":[{"name":"replaced 1"},{"name":"replaced 2"}]}')) | |
console.log('inside app',Object.is(me.wrapper.fromApp, me.wrapper.fromPrompt)); | |
},10000) | |
} | |
prompt() { | |
return this.dialogService.open({viewModel: Prompt, model: this.outer}); | |
} | |
} |
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> | |
<div repeat.for="s of outer.inner">${s.name}</div> | |
</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 Bar { | |
@bindable outer; | |
activate(data) { | |
this.outer = data; | |
} | |
} |
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(() => aurelia.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
<template> | |
<ai-dialog> | |
<ai-dialog-body> | |
<div repeat.for="i of outer.inner">${i.name}</div> | |
</ai-dialog-body> | |
<ai-dialog-footer> | |
<button click.trigger="controller.cancel()">Cancel</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 {DialogController} from 'aurelia-dialog'; | |
import {bindable} from 'aurelia-framework'; | |
import {Tracker} from './tracker'; | |
export class Prompt { | |
static inject = [DialogController, Tracker]; | |
@bindable outer; | |
constructor(controller, tracker){ | |
this.controller = controller; | |
this.tracker = tracker; | |
} | |
activate(outer) { | |
this.outer = outer; | |
this.tracker.fromPrompt = this.outer; | |
console.log('inside prompt', Object.is(this.wrapper.fromApp, this.wrapper.fromPrompt)) | |
} | |
} |
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 Tracker { | |
fromApp; | |
fromPrompt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment