[英]Unable to fetch data from asp.net core api into angular 6
net core api project in backend and using angular 6, using datatables plugin for displaying the grid , data is getting passed from the api but not getting shown in grid showing blank grid 后端的网络核心api项目并使用angular 6,使用datatables插件显示网格,数据正在从api中传递,但未显示在显示空白网格的网格中
following is service file code 以下是服务文件代码
export class DoctorsServiceService {
formData : DoctorVM;
readonly rootUrl = "https://localhost:44317/api/";
list: DoctorVM[];
constructor(private http:HttpClient) { }
getDoctors(){
this.http.get(this.rootUrl+"Doctors").toPromise().then(res => this.list =
res as DoctorVM[]);
}
}
following is html file code 以下是html文件代码
<table class="table table-striped" [mfData]="service.list" #mf="mfDataTable"
[mfRowsOnPage]="5">
<thead>
<tr>
<th>
<mfDefaultSorter by="name">Name</mfDefaultSorter>
</th>
<th>
<mfDefaultSorter by="email">Gender</mfDefaultSorter>
</th>
<th>
<mfDefaultSorter by="age">Specialities</mfDefaultSorter>
</th>
<th style="width: 20%">
<mfDefaultSorter by="city">AverageRating</mfDefaultSorter>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of mf.data">
<td>{{item.Name}}</td>
<td>{{item.Gender}}</td>
<td>{{item.Specialities}}</td>
<td>{{item.AverageRating}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
<mfBootstrapPaginator></mfBootstrapPaginator>
</td>
</tr>
</tfoot>
From the picture where you can actually see that data is available (there are rows) I am strongly suspecting that you're using a CamelCasePropertyNamesContractResolver
on the ASP side of the application. 从实际上可以看到数据可用(有行)的图片中,我强烈怀疑您在应用程序的ASP端使用的是CamelCasePropertyNamesContractResolver
。 That means even though your property names in C# will start with a capital letter, the returned JSON uses camel case (starting with a lower case letter) 这意味着即使您在C#中的属性名称将以大写字母开头,返回的JSON也会使用驼峰式大小写(以小写字母开头)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.