-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automatically create object structure #129
Comments
gitter discussion: ☝️ July 7, 2015 4:46 PM The request is to make the binding system automatically "define" undefined path expressions. Binding behavior maybe? |
@devmondo Do you mean that you get the word "undefined" appearing in the text box? If so, I think we should look into fixing that in the core. |
@EisenbergEffect yeah exactly, it is really troublesome with huge object structure, thanks :) |
@devmondo are you still able to reproduce this? This example works for me using the current bits: export class App {
user = {};
constructor() {
setInterval(() => this.debug = JSON.stringify(this.user), 500);
}
} <template>
<p>user = ${debug}</p>
<input type="text" value.bind="user.personal.name">
</template> |
@jdanyow it is working :) so you guys worked on it to make sure it is not false alarm? |
Nice- yeah I was just going through the binding repo issues to see what was outstanding. |
i dont know if it is me or not, but if i do this
i get inner error: TypeError: Cannot set property 'cool' of undefined
|
My guess is that your "personal" reference is undefined. We don't actually change your objects (I don't think), but the binding system can safely evaluate undefined paths. For your own code in JS, you will need to handle setting up all the references. |
@EisenbergEffect / @devmondo here's a plunkr that shows what happens: http://plnkr.co/edit/HnNmfzVqnQhsOkQCWpXn?p=preview once you type in the textbox you'll see the feature that @devmondo was asking for (magic creation of object structure). Personally I think this is weird and would not expect it to work this way but hey- it works 😉 Here's the code I think is responsible: https://github.com/aurelia/binding/blob/master/src/ast.js#L240-L243 |
Ah yes....it does work. I remember that. |
@jdanyow @EisenbergEffect i know it is weird, but sometimes it is really needed :) but hey you guys know what can and cant be done |
hi, i have the following scenario where i have user object
let user ={}
when i bind in html like this
<input value.bind="user.personal.name">
i get undefined in the textbox, but if i make user like this
let user={personal:{}}
undefined
in textbox goes away, i can understand this behavior if we are using something like c# because it is a statically typed languge but javascript is dynamic and left this constrain from us.please consider this, thanks in advanced.
The text was updated successfully, but these errors were encountered: