Initially my page loads data by the route. So normally the route is localhoat:8000\bProject
.
On the page there is a drop down menu, when I select the value I want the url changed by the value. It should be liking localhost:8000\CaseId\5
.
The Route code.
const routes: Routes = [
{path: 'bProject', component: BProjectComponent},
{path: 'bProject/CaseId/:id, component: BProjectComponent}
];
The drop down select value method is
private loadCaseData() {
const url = 'app/bProject/CaseId';
this.router.navigate([url, this.caseId]);
}
The code did work, however I found that the ngOnInit
was called twice. I doubt that there were two component instance running because in the routes, I use the same component twice.
Is it right to use navigation?