Now in the the component access the url parameters by subscribing to ActivatedRoute.queryParams observable.
url: http://localhost:4200/customer?name=test
import { ActivatedRoute } from '@angular/router';
@Component({ ... })
export class BookComponent implements OnInit {
name: string;
constructor(private route: ActivatedRoute) { }
ngOnInit() {
this.route.queryParams
.subscribe(params => {
console.log(params); // { name: "test" }
this.name= params.name;
console.log(this.name); // test
}
);
}
}
