Angularjs4.0如何实现路由的js跳转
Angularjs4.0如何实现路由的js跳转呢?具体步骤如下:1.引入
import { Router } from '@angular/router';
2.初始化
export class HomeComponent implements OnInit {
constructor(private router: Router) {
}
ngOnInit() {
}
goNews(){
//this.router.navigate(['/news', hero.id]);
this.router.navigate(['/news']);
}
}
3.路由跳转
this.router.navigate(['/news', hero.id]);
页:
[1]