I have the following code which works for displaying a modal:
app.html
<a click.delegate="setModal('person-information')">Test</a>
<modal>
<modal-header title.bind="'View Person'"></modal-header>
<modal-body content.bind="contentModal"></modal-body>
<modal-footer buttons.bind="['Cancel']"></modal-footer>
</modal>
app.js
setModal(modal) {
this.contentModal = modal;
$('.modal').modal();
}
person-information.html
<template>
<form role="form">
<div class="form-group">
<label for="fn">First Name</label>
<input type="text" value.bind="person.firstName" class="form-control" id="fn" placeholder="first name">
</div>
<div class="form-group">
<label for="ln">Last Name</label>
<input type="text" value.bind="person.lastName" class="form-control" id="ln" placeholder="last name">
</div>
</form>
</template>
person-information.js
import {bindable, inject} from 'aurelia-framework';
@inject(Element)
export class PersonInformation {
constructor() {
this.person = new Person();
}
}
class Person{
firstName = 'Patrick';
lastName = 'Bateman';
}
This code works fine for displaying the following:
I'm having trouble figuring out how I can inject my own data to dynamically create a "Person".
Pseudocode:
app.html
<a click.delegate="setModal('person-information', 'Tom', 'Hanks')">Test</a>
app.js
setModal(modal, firstname, lastname) {
this.contentModal = modal;
this.contentModal.Person.firstName = firstname;
this.contentModal.Person.lastName = lastname;
$('.modal').modal();
}
Has anybody had any experience doing this?