Open web-dave opened 4 years ago
ng g c fleet/vehicle-details
constructor(
private service: VehicleService,
private router: Router,
private route: ActivatedRoute) { }
selectVehicle(vehicle: IVehicle) {
this.router.navigate([vehicle.id], {relativeTo: this.route});
}
children: [{
path: '',
component: VehicleListComponent
}, {
path: ':id',
component: VehicleDetailsComponent
}]
<div class="panel panel-default" *ngIf="vehicle" >
<div class="panel-heading">{{vehicle.make}} ({{vehicle.model}})</div>
<div class="panel-body">
<p>{{vehicle.description}} <span class="badge">Sitze: {{vehicle.seats}}</span> </p>
<p>{{vehicle.type}}</p>
</div>
<div class="panel-footer">{{vehicle.department}}</div>
</div>
constructor(
private service: FleetService,
private router: Router,
private route: ActivatedRoute) { }
ngOnInit() {
this.route
.params
.subscribe((params: {id: string}) => {
this.service.getVehicle(params.id)
.subscribe(v => {
console.log('!!', v);
this.vehicle= v;
});
});
}
vehicle-details
componentvehicle-preview
should bring you to thisvehicle-details
component (RoutParams
)