Routes
const appRoutes: Routes = [
{ path: 'map/:id', component: mapComponent }]; //id is optional
Navigate the route
this.router.navigate(['map', '1', { 'center': 'taiwan' }]);
And the uri will be like this :
http://localhost:4200/map/1;center=taiwan
Map component
import {Router, ActivatedRoute} from '@angular/router';
export class mapComponent implements OnInit {
constructor(
private route: ActivatedRoute) {
}
ngOnInit() {
//Get route parameter
this.route.params.subscribe(params => {
let custIdValue = params['id'];
let centerValue = params['center'];
//Do somthing...
});
}
}
Reference : Angular Doc