gpt4 book ai didi

javascript - 如何在 AngularJS 中使用多个键值进行重复?

转载 作者:行者123 更新时间:2023-12-03 05:02:38 25 4
gpt4 key购买 nike

嗨,我有多个键和值的对象

Response 对象具有以下内容:

    Object
MainID:"589d8ddaf7045b29b5101cdc"
Url:Array[5]
0:Object
_id:"589d8ddaf7045b29b5101cdd"
url:"images/product_images/file-1486720474060.jpeg"
1:Object
_id:"589d8e1d142ef52a4ffb8285"
url:"images/product_images/file-1486720541230.jpeg"
2:Object
_id:"589d8eda142ef52a4ffb8288"
url:"images/product_images/file-1486720730226.jpeg"

这是我的 Angular 代码:

   $scope.data = response;

这是我的 html 代码:

    <div class="add-pic-box1 col-md-3" ng-repeat="datas in data">
<img class="thumb" ng-repeat="img in data.Url" ng-model="add_new_ads_mdl.img_add" imgid = "{{img._id}}" src="{{img.url}}" />
<span><i class="fa fa-times" ng-click="close_img(data.url._id)"></i></span>
</div>

有人可以帮我吗,提前谢谢..

最佳答案

问题出在你的 ng-repeat 上,应该是,子 ng-repeat 应该有 datas 而不是 data

 <div class="add-pic-box1 col-md-3" ng-repeat="datas in data">          
<img class="thumb" ng-repeat="img in datas.Url" ng-model="add_new_ads_mdl.img_add" imgid = "{{img.id}}" src="{{img.url}}" />

演示

angular.module('webapp', [])
.controller('AppCtrl', function($scope) {
$scope.data =
{
"id": 5454554,
"Url": [
{
"_id": "http://www.bcetupes.info/wp-json/wp/v2/posts/7194",
"url": "https://farm4.staticflickr.com/3261/2801924702_ffbdeda927_d.jpg"
}
]
} ;

});
<!DOCTYPE html>
<html ng-app="webapp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
</head>
<body ng-controller="AppCtrl">
<div class="add-pic-box1 col-md-3">
<div ng-repeat="img in data.Url" >
<h1>{{data.id}}</h1>
<img class="thumb" ng-model="add_new_ads_mdl.img_add" imgid = "{{img._id}}" src="{{img.url}}" />
</div>
<span><i class="fa fa-times" ng-click="close_img(data.url._id)"></i></span>
</div>
</body>
</html>

关于javascript - 如何在 AngularJS 中使用多个键值进行重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42156714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com