现在我在前端使用带有 Angular 6 的 ASP.NET,但不知道发生了什么。简而言之:尽管后端发送了正确的值,但我得到了一个空的 json:
模型:
import { Car } from '../models/car';
import { Ad } from '../models/ad';
export class Owner {
Id: number;
Firstname: string;
Lastname: string;
Phone: number;
Email: string;
Cars: Car[];
Ads: Ad[];
}
服务:
/** GET owners list */
getOwners (): Observable<Owner[]> {
return this.http.get<Owner[]>(this.ownersUrl)
.pipe(
catchError(this.handleError('getOwners', []))
);
}
所有者组件:
getOwners(): void{
this.ownerService.getOwners()
.subscribe( owners => this.owners = owners);
}
所有者HTML:
<nb-card class="nav-card">
<nb-card-body>
<nb-list>
<nb-list-item *ngFor="let owner of owners" >
{{owner.Id}}
</nb-list-item>
</nb-list>
</nb-card-body>
</nb-card>
我在做什么?服务不断给我空的 json 正文不好:/