Reputation: 740
I some template where i'm using repea.for
some times. There is a problem when I'm trying to bind data into bindable variables inside <editable-file-upload>
component.
I want to pass it like <editable-file-upload elem-id.bind="${elem.parent.id}">Upload</editable-file-upload>
but getting an error - aurelia-logging-console.js:54 ERROR [app-router] Error: Parser Error: Missing expected : at column 7 in [${elem.parent.id}]
. If I'm passing it so <editable-file-upload elem-id.bind="elem.parent.id">Upload</editable-file-upload>
value is undefined
. But it can't be undefined, because inside div.files-wrapper
I'm typyng those values and see right ones. How to pass it? I can't understand.
<div class="row">
<div class="col-md-12">
<div class="panel-group" id="someid" role="tablist" aria-multiselectable="true">
<div class="panel panel-default" repeat.for="elem of elems">
<div class="panel-heading" role="tab" id="${elem.parent.id}-heading">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#elems" href="#${elem.parent.id}" aria-expanded="false" aria-controls="#${elem.parent.id}">
<i class="glyphicon glyphicon-triangle-right"></i>${elem.parent.kood}
</a>
</h4>
</div>
<div id="${elem.parent.id}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="${elem.parent.id}-heading">
<div class="panel-body">
<div class="elem" if.bind="!elem.children.length">
<div class="files-wrapper">
<div class="files-message">Toimingul ei ole veel malle.</div>
<editable-file-upload elem-id.bind="${elem.parent.id}">Upload</editable-file-upload>
</div>
</div>
<div class="sub_elems" if.bind="elem.children.length">
<div class="sub_elem" repeat.for="subElems of elem.children">
<div class="sub_elem-title">${subElem.kood}</div>
<div class="files-wrapper">
${elem.parent.id}
${subElem.id}
<div class="files-message">Some text</div>
<editable-file-upload elem-id.bind="${elem.parent.id}" sub-elem-id.bind="${subElem.id}">Lae üles</editable-file-upload>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Upvotes: 0
Views: 915
Reputation: 11990
You're inside a repeat.for
and the property you want access belongs to the parent scope. So, you have to use $parent
keyword to get to the parent scope and then access the property. For instance:
<div class="files-wrapper">
${$parent.elem.parent.id}
${subElem.id}
<div class="files-message">Some text</div>
<editable-file-upload elem-id.bind="$parent.elem.parent.id"
sub-elem-id.bind="subElem.id">
Lae üles
</editable-file-upload>
</div>
</div>
Upvotes: 1