I have the following routing:
path: 'task', component: TaskComponent, children: [ { path: ':category/:id', component: TaskEditComponent } ] on my TaskComponent, I have a list of div that are clickable and will redirect to the path above
<div *ngFor="let url of urlList; let i = index" (click)="goToLink(url)"> this urlList contains: /task/personal/10 where personal is the category and 10 is the id.
Now on my TaskComponent, I have the goToLink method:
goToLink(url: string) { this._router.navigate([url]); } Now this is working, I can see that my url is changing. But i am not hitting the constructor or the OnInit method of the component specified on my routing which is TaskEditComponent. Please note that on first load, I am able to hit the constructor, but when I click other url on my div, i am not hitting it.
export class TaskEditComponent implements OnInit, OnDestroy { constructor() { } ngOnInit() { console.log('should hit this') } } I am reading life cycle hooks but I need help on what I am doing wrong here.
constructor(r: ActivatedRoute) { r.url.subscribe((s:UrlSegment[]) => { console.log("url", s); }); }, do you get logging when changing states?