Angularjs 返回到最后一页(模块),而不是最后一个状态
例如,在Typescript中,有没有办法获取最后一个模块而不是最后一个状态 如果有一条路线 从A页到B页, 内页B 从某个过程中,他添加了一些可选参数。Angularjs 返回到最后一页(模块),而不是最后一个状态,angularjs,typescript,routing,angular2-routing,aurelia,Angularjs,Typescript,Routing,Angular2 Routing,Aurelia,例如,在Typescript中,有没有办法获取最后一个模块而不是最后一个状态 如果有一条路线 从A页到B页, 内页B 从某个过程中,他添加了一些可选参数。 当单击“后退”按钮时,用户必须能够直接返回到A页,而无需前往B页的路线,无需可选参数此代码对我来说非常有用,可以访问最后一页的模块。请试一试 import { Router , NavigationEnd} from '@angular/router'; export class myComponent { private pr
当单击“后退”按钮时,用户必须能够直接返回到A页,而无需前往B页的路线,无需可选参数此代码对我来说非常有用,可以访问最后一页的模块。请试一试
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;
});
}
}
希望这能有所帮助。这实际上就是答案