角:如何从同一组件路由-参数?

时间:2018-10-16 14:30:58

标签: angular visual-studio asp.net-core

问题:每当我单击一个链接时,它都会选择两者。但是它可以正确显示各个链接。

enter image description here

当我单击链接时,我感到很开心,它并没有刷新整个路线。

我的代码:1.弯角路线:

{ path: 'gantt/:id', component: GanttWorkItemsComponent, data: { permission: 'Pages.WorkItems' }},
{ path: 'gantt', component: GanttWorkItemsComponent, data: { permission: 'Pages.WorkItems' } },

2.Component:

import { ActivatedRoute } from '@angular/router';

export class Gcomponent extens appComponent implements OnInit{

constructor(
    injector: Injector,
    private _http: Http,
    private _workItemsServiceProxy: WorkItemsServiceProxy,
    private params: ActivatedRoute) {

    super(injector);
    var paramId = params.snapshot.params["id"];

    if (paramId) {
        this.initiativeFilter = paramId;
        this.nameFilter = 'strategy.id=' + this.initiativeFilter;

    }
    } 

  ngOnit(){}

}

2 个答案:

答案 0 :(得分:1)

您应该订阅this.params.params,以便您的组件将在每次更改路线参数时进行更新

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

答案 1 :(得分:1)

尝试使用完全匹配选项设置有问题的链接DOM元素

[routerLinkActiveOptions]="{exact: true}"

可能的相关问题:

Why Angular2 routerLinkActive sets active class to multiple links?