adding allert onSearch button, fix redirecting

This commit is contained in:
2023-04-15 11:57:50 +02:00
parent 3bb31360d6
commit af090b9285
3 changed files with 23 additions and 10 deletions

View File

@@ -22,13 +22,11 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
public locationsPopup: Subject<Locations[]> = new Subject<Locations[]>()
subs: Subscription[] = []
subs: Subscription[] = [];
backgroundColor: string | undefined;
qrCodeImage: string | undefined;
locations: Locations[] = [];
allert: boolean = false;
locationsFiltrati: Locations[] = [];
luogoSelezionato: string = '';
suggerimentoAttivo: boolean = false;
@@ -51,8 +49,7 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
console.log(data[i])
}
});
this.allert = false;
console.log("home init");
this.subs.push(this.readjsonService.getLocation("Lugano").subscribe(val => console.log(val)))
const text = 'https://aramisgrata.ch'; // sostituisci con la tua stringa
@@ -174,8 +171,16 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
}
onSearch(): void {
const nomeLocation = encodeURIComponent(this.luogoSelezionato);
this.router.navigate(['/location', nomeLocation]);
if (this.luogoSelezionato === '') {
this.allert=true;
setTimeout(() => {
this.allert=false;
}, 8000);
return;
}else{
const nomeLocation = encodeURIComponent(this.luogoSelezionato);
this.router.navigate(['/location', nomeLocation]);
}
}
protected readonly Event = Event;