One of my functions stores the previous URL address.
prevId () {
let name, id, lat, lng;
this.router.events
.filter(event => event instanceof NavigationEnd)
.subscribe(e => {
console.log('prev:', this.previousUrl);
this.previousUrl = (e as NavigationEnd).url;
}
I've been attempting to rewrite this in an Observable-style format, but so far, nothing I try seems to work. Is there a way to make it possible? Also, can you recommend any good articles on Observables since I am new to this concept and it appears quite complex to me?
UPDATE: I need to access the data outside the function later on, hence the reason why I require an Observer.
For example:
myFun(a) {
console.log(a);
}
myFun(this.previousUrl);