0
美好的一天,我目前正在研究Ionic 2应用程序,并且我很难在下拉菜单上过滤所选项目上的数据库。根据在下拉列表中选择的项目过滤JSON API数据
这里是我的代码:
TS文件:
this.http.get('http://sample.com/xxx/api.php/address_province?transform=1')
.map(res => res.json())
.subscribe(data => {
this.province = data.address_province;
console.log(this.province);
}, (err) => {
console.log("Something went wrong.");
});
this.http.get('http://sample.com/xxx/api.php/address_city?transform=1')
.map(res => res.json())
.subscribe(data => {
this.city = data.address_city;
console.log(this.city);
}, (err) => {
console.log("Something went wrong.");
});
模板
<ion-item>
<ion-label>Province</ion-label>
<ion-select [(ngModel)]="registerprovince" >
<ion-option *ngFor="let prov of province" value="{{prov.province_description}}">{{prov.province_description}}</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>City</ion-label>
<ion-select [(ngModel)]="registercity" >
<ion-option *ngFor="let cities of city" value="{{cities.city_description}}">{{cities.city_description}}</ion-option>
</ion-select>
</ion-item>
我想要做的是,当我选择了一个省省下拉菜单,只有省下的城市才会显示在前面y下拉菜单。
我仍然不知道我将如何实现这种过滤在我的代码。希望你们能帮助我。先谢谢你。