Кто-нибудь подскажет, как мне разобрать мой ответ в AMP-списке. В AMP не нашли ни одного решения, как разобрать собственный ответ API.
Мой код.
<div
class="autosuggest-container hidden"
[class]="(showDropdown && query) ?
'autosuggest-container' :
'autosuggest-container hidden'"
>
<amp-list
class="autosuggest-box"
layout="fixed-height"
height="120"
src="http://lmyadpi.com/api.json?q=a"
id="autosuggest-list"
>
<template type="amp-mustache">
<amp-selector
id="autosuggest-selector"
keyboard-select-mode="focus"
layout="container"
on="
select:
AMP.setState({
query: event.targetOption,
showDropdown: false
}),
autosuggest-list.hide"
>
{{#results}}
<div
class="select-option no-outline"
role="option"
tabindex="0"
on="tap:autosuggest-list.hide"
option="{{.}}"
>{{.}}</div>
{{/results}}
{{^results}}
<div class="select-option {{#query}}empty{{/query}}">
{{#query}}Sorry! We don't ship to your city ?{{/query}}
</div>
{{/results}}
</amp-selector>
</template>
</amp-list>
</div>
</div>
<amp-state
id="allLocations"
src="http://lmyadpi.com/api.json?q=a"
"emptyAndInitialTemplateJson": [{
"query": "",
[[]]
}]
></amp-state>
Мой ответ API:
[[
"1234",
"value2",
""
],
[
"6321123",
"value3",
""
],
[
"43934322",
"value4",
""
],
[
"43660213",
"value5",
""
],
[
"54373228",
"value6",
""
],
[
"410721327",
"value7",
""
]]