ngOnInit() {
this.trip = this.fb.group({
id: '',
name: ['', [Validators.required, Validators.minLength(2)]],
});
this.route.paramMap
.switchMap((params: ParamMap) => this.tripService.getTrip(+params.get('id')))
.subscribe((trip: any) => {
this.trip.patchValue({
id: trip.id,
name: trip.name
});
})
}
ngOnInit() {
this.trip = this.fb.group({
id: '',
name: ['', [Validators.required, Validators.minLength(2)]],
});
this.route.paramMap
.switchMap((params: ParamMap) => {
console.log(params.get('id'))
if(params.get('id')){
this.tripService.getTrip(params.get('id')).subscribe((trip: any) => {
this.trip.patchValue({
id: trip.id,
name: trip.name
});
})
}
}
)
}