I am trying to pass and read data using Angular Route.navigate ,
On one component I have
this._router.navigate(["dashboard",{ queryParams: { page: 1 }}],
On Dashboard component I have
ngOnInit() {
this.sub = this._route
.queryParams
.subscribe(params => {
// Defaults to 0 if no query param provided.
let page = +params['page'] || 0;
console.log(page);
});
}
But this always return 0
Am I doing anything wrong?
My ng --version is
@angular/cli: 1.0.2
node: 6.3.1
os: darwin x64
@angular/common: 4.1.1
@angular/compiler: 4.1.1
@angular/core: 4.1.1
@angular/forms: 4.1.1
@angular/http: 4.1.1
@angular/platform-browser: 4.1.1
@angular/platform-browser-dynamic: 4.1.1
@angular/router: 4.1.1
@angular/cli: 1.0.2
@angular/compiler-cli: 4.1.1
IPLCEWKS01167:routeTest iplcewks01167$