Reputation: 2668
I am using ActivatedRoute
and subscribing to its params
to get triggered. But, the subscription is not triggering.
Code:
constructor(public activatedRoute: ActivatedRoute) {
this.activatedRoute.params.subscribe((params : any) => {
console.log(params);
});
}
I am unable to know the issue. Please help me solve this.
Thank you...
Upvotes: 2
Views: 2786
Reputation: 1339
you are missing queryParams
:
import { ActivatedRoute } from '@angular/router';
...
constructor( private _route: ActivatedRoute ) { }
...
ngOnInit() {
this._route.queryParams
.subscribe(
params => {
console.log(params);
});
}
Upvotes: 1
Reputation: 578
I am using the same in ngOnInit()
and it works..
You have syntax error i guess..(subscribe parenthesis)
this.activatedRoute.params.subscribe(params => {
console.log(params);
//call function here for data change
});
Upvotes: 1