When developing a service for my domain, I discovered that I could easily implement the service using any type like this:
list(): Observable<any> {
const url = this.appUrlApi + this.serviceUrlApi;
return this.http.get(url, { headers: this.header });
}
add(item: any): Observable<any> {
const url = this.appUrlApi + this.serviceUrlApi;
return this.http.post(url, item, { headers: this.header });
}
Instead of explicitly stating the Class like this:
list(): Observable<Car[]> {
const url = this.appUrlApi + this.serviceUrlApi;
return this.http.get(url, { headers: this.header });
}
add(item: Car): Observable<any> {
const url = this.appUrlApi + this.serviceUrlApi;
return this.http.post(url, item, { headers: this.header });
}
I understand that the second approach is the correct way and a better method (although the first way can save time by requiring fewer files and no commitment to properties), but what exactly are the benefits of defining model classes and their properties in Angular? It was meant to keep the Model as simple as possible in MVC.