hi,
is there a nice/easy way to access parent component models ?
if components are nested on multiple levels it becomes dirty very quick.
I think there is missing an "as" feature to give component models speaking names.
<my-businessmodel params="{}">
<my-panel params="{}">
// access values of businesscomponent here
// my-panel is also a component, thus access would be something ugly like:
// $parentContext.$component....
</my-panel>
</my-businessmodel>
as a workaround i found following, which is either not nice but makes the code more readable/maintainable:
<my-businessmodel params="{}">
<!-- next line is the workarond: -->
<!-- ko foreach: { data: [$component], as: 'myBusinessmodel'} -->
<my-panel params="{}">
// now we can access parentModel via the given name myBusinessmodel
<div data-bind="text: ko.toJSON( myBusinessmodel ) "></div>
</my-panel>
<!-- /ko -->
</my-businesscomponent>
anyone has a better solution for this ?
one idea might be a custom binding to expose component models , for example export which exports the component model ?
<my-businessmodel params="{}" data-bind="export: 'myBusinessmodel">
best regards,
noirabys