Access angular Singleton serice function in other class scope

Issue

i have a Singleton service class in Angular :

Solution

export class TripDetailsPage implements OnInit {

  currentTrip:Trip  new Trip("","")
  constructor(private router:Router, private tripService:TripService) { }

  ngOnInit() {
    this.currentTrip  this.tripService.getCurrentTrip();
    console.log(this.currentTrip);
  }

  switchToTab(path: string) {
    this.router.navigate(['home/trips/trip-details/' + path]);
  }
}

Answered By – StPaulis

Leave a Comment