Я новичок в разработке, и мне нужна помощь в этом вопросе, я хочу, чтобы данные переменной регионовFiltered внутри функции getCountry () глобально, а не только внутри функции
export class ShipmentManagementRegionPage {
countryRegion;
region;
mainRegion;
allRegions;
filteredRegions;
regionsFiltered;
constructor(public navCtrl: NavController, public events: Events, public commerceFunction: CommerceFunction, public navParams: NavParams, public storage: Storage, ) {
console.log(resgionsFiltered)
}
getCountry() {
this.commerceFunction.Getadm1Shipping().subscribe(data => {
this.mainRegion = data;
console.log(this.mainRegion)
this.storage.get("countryRegionList").then((data) => {
this.countryRegion = data;
console.log(this.countryRegion)
})
this.commerceFunction.GetGeoData_adm1OfCountry().subscribe(data => {
this.region = data;
for (let index = 0; index < this.mainRegion.length; index++) {
let commonCountryRegion = this.countryRegion.find(x => x.CountryRegionCode == this.mainRegion[index].CountryRegionCodeID);
this.mainRegion[index].CountryRegion = commonCountryRegion
let commonAdm1 = this.region.find(x => x.cc_fips == this.mainRegion[index].CountryRegionCodeID);
this.mainRegion[index].CountryRegion.adm1Shipping = commonAdm1
let commonRegions = this.region.filter(x => x.cc_fips == this.mainRegion[index].CountryRegionCodeID);
this.mainRegion[index].CountryRegion.geodata_adm1 = commonRegions
this.regionsFiltered = commonRegions;
}
this.rowData = this.mainRegion
});
})