samedi 20 juin 2020

If condition with && and || working only partially angular

I'm working on a condition where the user has to choose a departure and arrival airport and depending on the chosen route, he is redirected via routing to a dedicated plane component. The problem is that only the first part of the condition is working while the other is not routing. So if I choose departure in Warsaw and arrival in Paris all is good, and I reach the bombardier.component. But when I choose Paris first as departure and Warsaw as arrival, I'm taken into else condition which is flightdetails.component. The same applies to the rest of else if parts. What may be the cause here?

if (this.showStorage.departureAirport == "Warsaw" && this.showStorage.arrivalAirport == "Paris" || this.showStorage.departureAirport == "Paris" && this.showStorage.arrivalAirport == "Warsaw") {
  this.router.navigate(['/bombardier']);
}
else if (this.showStorage.departureAirport == "Warsaw" && this.showStorage.arrivalAirport == "New York" || this.showStorage.departureAirport == "New York" && this.showStorage.arrivalAirport == "Warsaw") {
  this.router.navigate(['/boeing787']);
}

else if (this.showStorage.departureAirport == "Paris" && this.showStorage.arrivalAirport == "New York" || this.showStorage.departureAirport == "New York" && this.showStorage.arrivalAirport == "Paris") {
  this.router.navigate(['/boeing737']);
} else {
  this.router.navigate(['/flightdetails']);
}

Thanks for helping find the solution here.

Aucun commentaire:

Enregistrer un commentaire