routing - Angular 4 RouterLink does not work correctly -


my app.component.html consists of 3 componenets , looks follows:

<app-menu></app-menu> <app-footer></app-footer> <app-control-sidebar></app-control-sidebar> 

inside app-menu.component i'm adding links dynamically:

<li *ngfor="let statistic of statistics"><a [routerlink]="['/chart', statistic.appname]" ><i class="fa fa-pie-chart"></i>{{statistic.appname}}</a></li> 

routes definition:

const routes: routes = [      { path: 'chart/:name', component: chartcomponent } ];  export const routing: modulewithproviders = routermodule.forroot(routes); 

chart.component implements oninit , ondestroy:

ngondestroy() {         this.sub.unsubscribe();     }   ngoninit() {          this.sub = this.route.params.subscribe(params => {             this.urlname = params["name"];                     setinterval(() => {                         this.performupdate();                     }, 3000);          });        } 

let's menu consists of 5 statistics. when select statistic correct chart. works first time - if click on next 1 nothing happens , url not updated.

what wrong?

all code available here


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -