Q:

route back to last page(module) instead of last status

In Typescript is there any way to get the last module instead of last status, As an example 
if some one routes
from  page A to page B ,
inside page B 
from some proceeding he adds some optional parameters.
when the back button clicks user has to be able to go back to page A directly without going to the route that Page B without optional parameters

A:

This code worked for me to get the module of the last page visited. Pls try.
import { Router , NavigationEnd} from '@angular/router';

  export class myComponent {
    private previousUrl: string;

    constructor(private router: Router){

      router.events
         .filter(event => event instanceof NavigationEnd)
         .subscribe(e => {
            let path = this.previousUrl;
            if(path !="" && path!=undefined){
               let res = path.split("/");
               console.log(res[1]); /* here in res[1] you will get the last clicked page module url. Now you can route to last module using this res[1] value */
            }
         this.previousUrl = e.url;

      });
   }
 } 

Hope this helps.

