访问父数据库中的数组$scope子级(节点MongoDB Javascript)
我正在我的节点应用程序中运行以下代码: 控制器访问父数据库中的数组$scope子级(节点MongoDB Javascript),javascript,angularjs,node.js,Javascript,Angularjs,Node.js,我正在我的节点应用程序中运行以下代码: 控制器 Shirts.get({ shirtId: $stateParams.shirtId, cat: $stateParams.cat },function(response){ $scope.Beta = response; }); Shirts.get({ shirtId: $stateParams.shirtId, cat: $stateParams.cat },function(response){ $
Shirts.get({ shirtId: $stateParams.shirtId, cat: $stateParams.cat },function(response){
$scope.Beta = response;
});
Shirts.get({ shirtId: $stateParams.shirtId, cat: $stateParams.cat },function(response){
$scope.Beta = response.category[0];
});
看法
看法
如何访问$scope中的数组内部的数组
谢谢你是说我从第一个代码收到的响应?响应是一个数组,不是吗?使用
ng repeat=“sh in Beta”
可以迭代该数组。是的,我在控制台中得到的是响应!好的,关于您的代码示例和错误,您发现它看起来像一个数组,只需尝试$scope.Beta=response[0].category代码>在第一个代码中,按响应重复循环,因此sh
inside-类似于response[0]
等等
Shirts.get({ shirtId: $stateParams.shirtId, cat: $stateParams.cat },function(response){
$scope.Beta = response.category[0];
});
<ul>
<li ng-repeat="sh in Beta">
<input type="text" data-ng-model="sh.name" id="name" >
<input type="text" data-ng-model="sh._id" id="name" >
</ul>
{ _id: 556ab2a4789bf9769ea813e0, category: [ { name: 'aa', _id: 556ab2a4789bf9769ea813e3, picture: [] } ] }