Using Aurelia, you can put stuff in the container and then inject it. The container state is not shared in the dialog.
Is there a way to get the data I injected in the container, and use it inside the dialog?
Code example
home.js
fetchString(){
this.data = JSON.parse(stringform);
this.container.registerInstance('tpscform', this.data);
}
custom-element.js
import {DialogService} from 'aurelia-dialog';
import {LookupFieldsDialog} from './dialog/lookup-fields-dialog';
@inject('tpscform', DialogService)
export class LookupFieldsQuestion {
constructor(form, dialog){
console.log(form); // returns the object from the container - works
//...
}
submit() {
this.dialogService.open({
viewModel: LookupFieldsDialog,
model: this.question,
lock: false
});
}
}
lookup-fields-dialog.js
import {inject} from 'aurelia-framework';
import {DialogController} from 'aurelia-dialog';
@inject(DialogController, 'tpscform')
export class LookupFieldsDialog {
constructor(controller, form) {
this.controller = controller;
console.log(form); // Returns the string 'tpscform' - doesn't work
}
activate(question) {
this.question = question;
}
}