【发布时间】:2015-11-02 14:49:15
【问题描述】:
我使用这个函数从网络服务中读取数据
$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-repeat 显示这个结果
<tr ng-repeat="p in produits">
<td>{{p.reference}}</td>
<td>{{p.designation}}</td>
<td>{{p.prix}}</td>
</tr>
但这行不通 我想在我的模型中提取这些信息:
{
"reference": 1,
"designation": "sony",
"prix": 5100
}
因为我有两个实体 product(id,designation,prix) 和 categorie(id,nom) 在关联 ManytoOne 我如何使用 angularJS 做到这一点?
【问题讨论】:
-
ng-repeat 需要数组,你的 $scope.produits 对象不是数组?
标签: javascript json angularjs