I am learning angular, in my project my navigation bar I have created routerLink provides for navigating to the page.
<ul> <li> <a href="#">Home</a></li> <li> <a href="#" [routerLink]="['/about']" >about us</a></li> <li> <a href="#" [routerLink]="['/contact']" >contact us</a></li> </ul> and this is my app.module.ts , in which I have set router for navigation.
imports: [ BrowserModule, HttpModule, RouterModule.forRoot([ { path:"**", component: HomeComponent,pathMatch: 'full' }, { path:"about", component: AboutComponent }, { path:"contact" , component: ContactComponent } ]) ], so, this runs perfectly when I run it goes first to the home page but when I click on about us page and contact page in query string router will change but content not changes, the content of the home page is same as it is, here is my homepage and about us page. this is m home.component.ts
constructor(private _avRoute: ActivatedRoute, private _cmsService: CmsService, private _router: Router) { } ngOnInit() { this.getConsultHome(); } getConsultHome(){ this._cmsService.getcmsConsultHome() ._router.params.subscribe(data =>{ this.data = data } , error => this.errorMessage = error); } and this is my about.component.ts
constructor(private _avRoute: ActivatedRoute, private _cmsService: CmsService, private _router: Router) { } ngOnInit() { this._cmsService.getcmsConsultAbout() .subscribe(data =>{ this.data = data } , error => this.errorMessage = error); } Please, anyone helps me, I am stuck on the problem.I seen many questions related to this but not as much useful and solve my query, Thanks in advance