I'm currently working on an app where I need to retrieve posts by user before displaying a specific post based on its id when clicked. However, I encountered the following errors:
ERROR in src/app/cars/car-detail/car-detail.component.ts(25,11): error TS2322: Type 'Observable<{ _id: string; title: string; content: string; imagePath: string; creator: string; }>' is not assignable to type 'Car[]'.
The property 'includes' is missing in type 'Observable<{ _id: string; title: string; content: string; imagePath: string; creator: string; }>'.
src/app/cars/car-detail/car-detail.component.ts(26,11): error TS2322: Type 'number' is not assignable to type 'string'.
import { Input, Component, OnInit } from '@angular/core';
import { Car } from '../car.model';
import { CarsService } from '../cars.service';
import { ActivatedRoute, Params } from '@angular/router';
@Component({
selector: 'app-post-detail',
templateUrl: './post-detail.component.html',
styleUrls: ['./post-detail.component.css']
})
export class PostDetailComponent implements OnInit {
@Input() post: Post[] = [];
@Input() id: string;
constructor(
private postsService: PostsService,
private route: ActivatedRoute
) { }
ngOnInit() {
this.route.params
.subscribe(
(params: Params) => {
this.post = this.postsService.getPost(this.id);
this.id = +params['id'];
}
);
}
}
How can I resolve these issues?