1. 1. 在路由中配置动态路由
    2. {
    3. path:'newcontent/:aid',
    4. component:LoginComponent
    5. },
    6. 2. 传值
    7. //list为一个数组经过for循环后加入小于10的数
    8. <ul>
    9. <li *ngFor="let item of list;let key = index">
    10. <a [routerLink]="[ '/newcontent/', key ]">{{key}} -- {{item}}</a>
    11. </li>
    12. </ul>
    13. 3.接收传值
    14. //导入接受传值模块
    15. import { ActivatedRoute } from '@angular/router'
    16. //实例化
    17. export class LoginComponent implements OnInit {
    18. constructor(public route:ActivatedRoute) { }
    19. ngOnInit() {
    20. //接受传值
    21. this.route.params.subscribe(res=>{
    22. console.log(res);
    23. })
    24. }
    25. }