我用這個功能去提取對象從Web服務如何我可以從JSON結果usinig angularJS
$scope.getProduitByCatID = function() {
$http.get("/getProduitByCategorieID?id=" + $scope.categorie.id).success(function (data) {
$scope.produits = data;
});
};
讀取數據
在我的模型$scope.produits
值:
{
"reference": 1,
"designation": "sony",
"prix": 5100,
"categorie": {
"id": 1,
"nom": "serveur"
}
}
我想說明這個結果與NG重複
<tr ng-repeat="p in produits">
<td>{{p.reference}}</td>
<td>{{p.designation}}</td>
<td>{{p.prix}}</td>
</tr>
,但它不能正常工作 我WA NT在我的模型只提取這樣的信息:
{
"reference": 1,
"designation": "sony",
"prix": 5100
}
,因爲我有兩個實體product(id,designation,prix)
和協會多對一categorie(id,nom)
我怎麼能做到這一點使用angularJS?
ng-repeat需要數組,你的$ scope.produits對象不是數組? –