繁体   English   中英

无法从asp.net核心api获取数据到angular 6

[英]Unable to fetch data from asp.net core api into angular 6

后端的网络核心api项目并使用angular 6,使用datatables插件显示网格,数据正在从api中传递,但未显示在显示空白网格的网格中

以下是服务文件代码

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[]);
}
}

以下是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>

空白网格图像

从实际上可以看到数据可用(有行)的图片中,我强烈怀疑您在应用程序的ASP端使用的是CamelCasePropertyNamesContractResolver 这意味着即使您在C#中的属性名称将以大写字母开头,返回的JSON也会使用驼峰式大小写(以小写字母开头)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM