我需要以离子格式的表格格式显示以下响应,为此我在离子格式中使用网格,我需要复制此表here并将其显示在离子格式表中。有效的json格式。
{
"success": true,
"data": {
"1": {
"Sales": {
"Total Sales": "0.94",
"Non-VAT": "0.20",
"Baskets": "188",
"Avg Basket": "497",
"Known Customers": "2",
"Discounts": "317",
"Owners": "-",
"Staff": "658",
"Margin": "16.39",
"Profit": "13,062"
},
"Accounts": {
"Register": "-",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "424",
"-ve QOH": "343",
"Items": "40,849",
"Stock": "26.11",
"Replication": "Yes"
}
},
"2": {
"Sales": {
"Total Sales": "4.08",
"Non-VAT": "1.01",
"Baskets": "580",
"Avg Basket": "704",
"Known Customers": "21",
"Discounts": "2,820",
"Owners": "814",
"Staff": "1,972",
"Margin": "18.50",
"Profit": "63,163"
},
"Accounts": {
"Register": "-",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "479",
"-ve QOH": "300",
"Items": "11,593",
"Stock": "88.14",
"Replication": "Yes"
}
},
"3": {
"Sales": {
"Total Sales": "3.85",
"Non-VAT": "0.25",
"Baskets": "380",
"Avg Basket": "1,013",
"Known Customers": "-",
"Discounts": "0",
"Owners": "-",
"Staff": "-",
"Margin": "9.36",
"Profit": "32,720"
},
"Accounts": {
"Register": "1",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "98",
"-ve QOH": "45",
"Items": "4,190",
"Stock": "79.99",
"Replication": "-"
}
},
"4": {
"Sales": {
"Total Sales": "1.91",
"Non-VAT": "0.10",
"Baskets": "247",
"Avg Basket": "774",
"Known Customers": "-",
"Discounts": "0",
"Owners": "-",
"Staff": "-",
"Margin": "9.71",
"Profit": "16,775"
},
"Accounts": {
"Register": "29,160",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "229",
"-ve QOH": "187",
"Items": "5,885",
"Stock": "30.56",
"Replication": "Yes"
}
},
"5": {
"Sales": {
"Total Sales": "1.28",
"Non-VAT": "0.19",
"Baskets": "285",
"Avg Basket": "449",
"Known Customers": "8",
"Discounts": "521",
"Owners": "-",
"Staff": "1,966",
"Margin": "18.34",
"Profit": "19,639"
},
"Accounts": {
"Register": "45,525",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "299",
"-ve QOH": "219",
"Items": "10,923",
"Stock": "36.54",
"Replication": "Yes"
}
},
"6": {
"Sales": {
"Total Sales": "-",
"Non-VAT": "-",
"Baskets": "-",
"Avg Basket": "-",
"Known Customers": "-",
"Discounts": "-",
"Owners": "-",
"Staff": "-",
"Margin": "-",
"Profit": "-"
},
"Accounts": {
"Register": "-",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "-",
"-ve QOH": "-",
"Items": "-",
"Stock": "-",
"Replication": "-"
}
},
"7": {
"Sales": {
"Total Sales": "0.79",
"Non-VAT": "0.14",
"Baskets": "187",
"Avg Basket": "421",
"Known Customers": "6",
"Discounts": "717",
"Owners": "1,078",
"Staff": "161",
"Margin": "16.46",
"Profit": "11,034"
},
"Accounts": {
"Register": "22,536",
"Cash Close Date": "-",
"Cash Excess\/ Short": "-",
"Cash In Hand": "-"
},
"Alerts": {
"-ve Batches": "454",
"-ve QOH": "397",
"Items": "8,746",
"Stock": "31.30",
"Replication": "Yes"
}
}
}
}
我是离子学的初学者,正在学习。我尝试查找资源,但不愿意管理。
这是我的ts文件。
export class HomePage {
data:any;
alldata: Observable<any>; //<-- this add first
fewdata: Observable<any>;
constructor(public navCtrl: NavController,
private http: Http) {
// window.open("http://google.com",'_system', 'location=yes');
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let options = new RequestOptions({ headers: headers });
this.http.post('http://url/foldername/filename.php',options)
.map(res => res.json())
.subscribe(data => {
console.log("Api Fired",data);
//this.data =data;
this.alldata = data; //<--this add
console.log("Api Fired Again",this.alldata);
});
}
}
我的html文件
<ion-content padding>
<ion-content>
<ion-grid>
<ion-row *ngFor="let item of alldata?.data">
<ion-col>
{{item}}
</ion-col>
<ion-col>
{{item}}
</ion-col>
<ion-col>
{{item}}
</ion-col>
<ion-col>
{{item}}
</ion-col>
<ion-col col-2.4>
{{item}}
</ion-col>
<ion-row>
<ion-grid>
<ion-content>
</ion-content>