I have this routing
{
path: ':lang',
children: [
{
path: 'page',
children: [
{
path: '',
component: PageComponent
},
{
path: ':Id',
component: PageComponent
}
]
},
...
}];
and my component looks like this:
export class PageComponent implements OnInit {
busy: any;
pages: Page[];
src: any;
constructor(private httpCall: HttpCall, private router: Router, private activedRoute: ActivatedRoute, public languageService: LanguageServiceService, private http: Http) {
}
ngOnInit() {
let Id = this.activedRoute.snapshot.params['Id'];
this.busy = this.httpCall.get('/pub/page/GetPageById/' + Id)
.subscribe(
data => {
this.pages = <Page[]>data;
})
}
}
When I first visit for example
domain.com/en/page/13
it redirects normally but If I'll try to redirect to
domain.com/en/page/14
from there it changes url but inside page everything is left as it is.
I think it's because of ngOnInit
is rendering only once until I'll go in another url (outside of page)
How can I solve that?