这是角度2路由代码
<nav>
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a routerLink="/dashboard" routerLinkActive="active">Step I</a></li>
<li role="presentation"> <a routerLink="/faculty" routerLinkActive="active">Step II</a></li>
<li role="presentation"><a routerLink="/heroes" routerLinkActive="active">Step III</a></li>
</ul>
</nav>
<router-outlet></router-outlet>
按钮点击事件
clickFunctionEvent(value: any) {
this.dataService.setFacultyAnswer(JSON.stringify(value)).subscribe(
tradeshows => {
this.data= tradeshows
//if data=success then redirect to next routerLink like "/faculty"
},
error => {console.error('QuestionList:\n\t ' + error);}
);
}
如果data=success
然后重定向到下一个routerLink,例如"/faculty"
所以如何在.ts
文件中
how to disable previous routerLink so not allow to go back
提前致谢
答案 0 :(得分:28)
你使用
//in your constructor
constructor(public router: Router){}
//navigation link.
this.router.navigate(['your-route']);