使用自定义字段重置angular4中的下拉值
在将旧的angular应用程序迁移到angular 4时,我在.js文件中遇到了这个问题 自定义下拉列表使用自定义字段重置angular4中的下拉值,angular,angular4-forms,angular4-router,Angular,Angular4 Forms,Angular4 Router,在将旧的angular应用程序迁移到angular 4时,我在.js文件中遇到了这个问题 自定义下拉列表 hps-dropdown model="studentRequest.CountryType" reset-id="countryResetId" is-required="false" options="countryOptions" reset- id="resetCountryRequestResetId">hps-dropdown 如何在angular 4中使用reset
hps-dropdown model="studentRequest.CountryType" reset-id="countryResetId"
is-required="false" options="countryOptions" reset-
id="resetCountryRequestResetId">hps-dropdown
如何在angular 4中使用resetid
代码:
function setDefaultCountry() {
var queryParams = $location.search();
if (queryParams.Region) {
---
---
});
if (RegionsArray.length > 0) {
Code = selectedArray[0].id;
// Reset the id to reflect values in drop down
this.countryResetId = new Date();
}
}
}
如何在angular 4中调用相同的来保持不变
但是当我开始实现时,我使用了普通的组合框而不是上面的模板,并绑定了所需的选项
<select class="form-control" id="country" name="country" (change)="onCountryChange($event.target.value)" [(ngModel)]="countrySelected" required>
<option value='' disabled="disabled">select</option>
<option *ngFor="let country of countryList">{{country.name}}</option>
</select>
选择
{{country.name}
基本上,首先加载国家,然后根据它加载国家。因此,您希望下拉列表的默认值必须类似于“选择国家”,一旦选择国家,就应该加载国家。。。如果我的理解有误,请纠正我?显示您的代码。