[英]Load amp-list data only after event
I'm trying to figure out a way to only load the data on my second amp-list only when the first one has any selected value, i also can't find a way to make the second amp-list placeholder shows up. 我试图找出一种只在第一个放大器列表中加载数据的方法,只有当第一个放大器列表中有任何选定的值时,我也找不到让第二个放大器列表占位符显示的方法。
<div class="row">
<div class="col-sm-4 position-inherit">
<div class="form-group tt-dark select-site">
<amp-state id="states" src="/BuscaEstadosAmpRequest?isLead=true&isTeste=false&isMapa=false"></amp-state>
<amp-list layout="fixed-height"
height="40"
src="/BuscaEstadosAmpRequest?isLead=true&isTeste=false&isMapa=false"
single-item
items="."
noloading
binding="no">
<template type="amp-mustache">
<select id="stateGeo" on="change:
AMP.setState({
selectedState: states.items.filter(x => x.ID == event.value)[0]
}); cities.refresh">
<option value="" [disabled]="selectedState">UF</option>
{{#items}}
<option value="{{ID}}">{{Sigla}}</option>
{{/items}}
</select>
</template>
</amp-list>
</div>
</div>
<div class="col-sm-8">
<div class="form-group tt-dark select-site">
<amp-state id="cities"
[src]="'/BuscaCidadesAmpRequest?isLead=true&isTeste=false&isMapa=false&estadoId=' + selectedState.ID">
</amp-state>
<amp-list layout="fixed-height" height="40" [src]="cities" single-item items="." noloading binding="no">
<template type="amp-mustache">
<select id="cityGeo" on="change:
AMP.setState({
cityId: event.value
})">
<option value="">ESCOLHA UMA CIDADE</option>
{{#items}}
<option value="{{ID}}">{{Nome}}</option>
{{/items}}
</select>
</template>
<div placeholder role="listitem">
<select disabled>
<option value="">ESCOLHA UMA CIDADE</option>
</select>
</div>
</amp-list>
</div>
</div>
<div class="form-group tt-dark select-site">
<amp-state id="units"
[src]="'/BuscaUnidadesAmpRequest?isLead=true&isTeste=false&isMapa=false&cidadeId=' + selectedCity.ID">
</amp-state>
<amp-list layout="fixed-height" height="40" [src]="units" single-item items="." noloading>
<template type="amp-mustache">
<select id="unitGeo" on="change:
AMP.setState({
unitId: event.value
})">
<option value="">ESCOLHA UMA UNIDADE</option>
{{#items}}
<option value="{{ID}}">{{NomeFantasia}}</option>
{{/items}}
</select>
</template>
</amp-list>
</div>
</div>
If it's not possible to do what i wanted, what would be the best option on this? 如果不可能做我想做的事,那么最好的选择是什么?
Also how could i disable the first option to prevent the user from ever selecting it? 另外我怎么能禁用第一个选项来阻止用户选择它?
<option value="" [disabled]="selectedState">UF</option>
EDIT Forgot to mention two things, how would i manually update the amp-state for the cities manually after i selected the state? 编辑忘了提两件事,我选择状态后如何手动更新城市的放大器状态? And how do i manually start a state with a default value?
我如何手动启动默认值的状态? I tried to use the following but always ended-up with a warning that the state is null:
我尝试使用以下内容但总是以状态为空的警告结束:
<amp-state id="teste">
<script type="application/json">
{
"ID": 0,
"Nome": "",
"Sigla": ""
}
</script>
</amp-state>
how do i manually start a state with a default value?
如何手动启动默认值的状态? I tried to use the following but always ended-up with a warning that the state is null
我尝试使用以下内容,但总是以状态为空的警告结束
you can't - there is no initial state in amp-bindings. 你不能 - 在放大器绑定中没有初始状态。 You have to populate the html element and only use amp-bind when updating the value.
您必须填充html元素,并在更新值时仅使用amp-bind。
You could go this way: 你可以这样走:
{{#items}}
<option value="{{ID}}" {{SELECTED}}>{{Nome}}</option>
{{/items}}
and change you're json-object to something like that: 并将你的json-object更改为类似的东西:
{
"id" : "1",
"name" : "Paris",
"selected" : "selected"
}
should do the job 应该做的工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.