Right now, I am encountering the following obstacle while working with aurelia:
Based on my user-model:
export class User{
@bindable name: string;
@bindable address: Address;
I have a layout view-model that includes a form:
Parent UserRegistration JS
export class UserRegistration{
@bindable user: User
public registerUser(){
let address = this.user.address;
//register user and so on ...
}
}
Parent UserRegistration template
<template>
<require from="user-address"></require>
<form id="user-registration-form" submit.delegate="registerUser()>
<user-adress user.bind="user"></user>
</form>
</template>
Additionally, I have a custom-element:
CustomElement userAddress JS
@customElement('userAddress')
@autoinject
export class userAddress{
@bindable user: User;
}
CustomElement userAddress template:
<template>
<input type="text" id="street-name" value.bind="user.address.streetname" />
</template>
My goal is to have the information from the custom-element "user-address" transferred to the layout view-model when the submit button is clicked, so that I can utilize it in the "registerUser()" function.
Does anyone have a solution on how to achieve this? Currently, I am only getting an "undefined" value in the parent view-model.