Closed aghassemi closed 6 years ago
If @gustavopaes hasn't already found a workaround, the following example can work. If you can change the endpoint, you can wrap the data for amp-list
in a single-item array and render all of amp-selector
inside the amp-list
template e.g.
{"items": [{
"docs": [/*...*/]
]}
<amp-list
src="https://carros.uol.com.br/service.htm?type=areas/carros/fipe-table-api&args={'params':{'category':1}}&json"
height="100"
width="100"
[src]="controller.category == false ? '' : config.service"
layout="responsive"
>
<template type="amp-mustache">
<amp-selector
name="fipe-category"
layout="container"
on="select:AMP.setState({controller: {category: event.targetOption}})"
>
<ul>
{{#docs}}<li option="{{.}}" value="{{.}}">{{.}}</li>{{/docs}}
</ul>
</amp-selector>
</template>
</amp-list>
Would that put an amp-selector into each rendered item?
amp-selector
would only render once. There is only one rendered "item" since the items array only has one element. It wraps the object containing docs
so that the whole template isn't repeated multiple times. I used a similar strategy for my autocomplete demo.
Ah, interesting workaround!
Oh! I forgot, the option
attribute needs to be whitelisted in templates before this will work anyway. That is part of PR #9553
cool workaround!
This issue hasn't been updated in awhile. @camelburrito Do you have any updates?
This issue hasn't been updated in awhile. @camelburrito Do you have any updates?
This issue hasn't been updated in awhile. @aghassemi Do you have any updates?
Taking this issue
if
amp-list
renders newoptions
inside anamp-selector
,amp-selector
has no idea and does not rescan children to find these new options.Repro case from @gustavopaes
/to @camelburrito /cc @gustavopaes