Angularjs4.0路由的js跳转 获取get传值
Angularjs4.0路由的js跳转 get传值是如何获取的呢?我们可以通过以下三个步骤来完成:1.引入NavigationExtras
import { Router ,NavigationExtras,ActivatedRoute} from '@angular/router';
2.定义一个goNewsContent方法执行跳转,用NavigationExtras配置传参
goNewsContent(){
let navigationExtras: NavigationExtras = {
queryParams: { 'session_id': '123' },
fragment: 'anchor'
};
this.router.navigate(['/news'],navigationExtras);
}
3.获取get传值
constructor(private route: ActivatedRoute) {
console.log(this.route.queryParams);
}
页:
[1]