![](/img/trans.png)
[英]Unable to post values from angular service to Web API in asp.net core angular
[英]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.