简体   繁体   English

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

[英]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>

Blank Grid Image 空白网格图像

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.

相关问题 无法将值从angular服务发布到asp.net core angular中的Web API - Unable to post values from angular service to Web API in asp.net core angular 无法使用 NgModel 将带有附件的 SharePoint 列表项从 Angular 添加到 ASP.NET Core Web API - Unable to add SharePoint list item with attachment from Angular to ASP.NET Core Web API using NgModel 无法将文件从Angular 8上传到Asp.net Core 2.2 - Unable to File Upload From Angular 8 to Asp.net Core 2.2 Angular 5+消耗来自ASP.NET Core Web API的数据 - Angular 5+ consume data from asp.net core web api 从Angular 2前端到Asp.Net Core Web API的JSON数据发布-丢失值 - JSON data posts from Angular 2 front end to Asp.Net Core web api - loses values 如何从 Angular 中的本地 Web API (ASP.NET Core) 获取数据 - How to get data from local Web API (ASP.NET Core) in Angular 角度通用视图源未显示来自asp.net Web API核心的数据 - Angular universal view source not showing data from asp.net web API core Angular - 使用 ASP.NET 内核从相关表中检索数据 Web ZDB974238714CA8DE634A7CE1DZF08A3 - Angular - retrieve data from related tables with ASP.NET Core Web API 如何从Angular读取数据到Asp.net Core - How to Read Data come from Angular to Asp.net Core 从Asp.net Core读取数据到Angular 7 - Read Data from Asp.net Core to Angular 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM