onSelectRegion(selectedRegionName: any) { const selectedRegion =…
- User
onSelectRegion(selectedRegionName: any) {
const selectedRegion = this.regions.find((region:any) => region.name === selectedRegionName); if (selectedRegion) { this.selectedAreas = selectedRegion.area; this.selectedOrderCustomer.area = null; this.selectedOrderCustomer.district = null; this.selectedOrderCustomer.government = selectedRegion.name; this.lastSelectedRegion = selectedRegion.name;code} else { this.selectedAreas = []; this.selectedOrderCustomer.area = null; this.selectedOrderCustomer.district = null; }} i want when area didn't selected also district didn't selected and show select district, district is subarray from area and area is subarray from region(government)
- Assistant
Certainly! Based on your description, you want to ensure that when no area is selected, the district should also be set to null, and a message to select a district should be displayed. Here's how you can modify your method to accommodate this requirement:
- User
no i want if i didn't yet select area not if (this.selectedAreas.length === 0
- Assistant
Got it! If you want to ensure that when no area has been selected, the district is also set to null and a message is displayed, you can manage the selection states more directly. Here's how you can modify your
onSelectRegionfunction to reflect this:javascript - User
i have selectedDistrictsArray i want to reset it in case of i select new region then select new area, but when i do this effect on function onSelectArea(SelectedAreaName:any){ debugger const selectedArea = this.selectedAreas.find((area:any) => area.name === SelectedAreaName);
codeif (selectedArea) { if(this.selectedDistricts.length==0){ this.selectedDistricts=[]; this.selectedDistricts = selectedArea.district; }else{ this.selectedDistricts = selectedArea.district; this.selectedOrderCustomer.district = null; this.selectedOrderCustomer.area = selectedArea.name; this.lastSelectedArea = selectedArea.name; } } else { this.selectedDistricts = []; this.selectedOrderCustomer.district = null; }} which sometimes i chnage only area
- Assistant
- User
still issue when i select area after selection of region the select district option disaapear from input
- Assistant
- User
] i want to check in onselectregion function if i have selected list and no selected area ,show select distirct option beacuase when i reselect region the selected district appeared even i didn't select area yet
- Assistant