【发布时间】:2016-12-05 07:26:24
【问题描述】:
我需要为以下图像数组中的每个图像添加一个描述,这些图像可以在这个对象中找到:
[
{
"id": "Movie Poster Remixes",
"name": "HULK Remix",
"practices": ["Graphics", "Sketching", "Artwork", "Vector Manipulation"],
"technology": ["Inkscape", "Photoshop"],
"time": "3 Weeks",
"description": "A series of poster remixes I have one over the past couple of years. I tend to spend any free time working on some graphical artwork which tends to be printed off & framed in my house.",
"images": [
"../assets/img/details/15/1.jpg",
"../assets/img/details/15/2.jpg",
"../assets/img/details/15/3.jpg",
"../assets/img/details/15/4.jpg"
],
"header": "../assets/img/paramount-logo.svg",
"behance": "https://www.behance.net/gallery/26358303/Avengers-Hulk-Desktop-WallPaper-Design"
}
]
我似乎无法完成这项工作。图像显示在视图中,但看不到如何添加描述。
任何帮助将不胜感激。 TIA。
这就是我当前访问控制器中的对象并将某些键值绑定到范围的方式。
$http.get('app/resources/v1/projects/' + $routeParams.id + '.json').success(function (details) {
$scope.details = details;
angular.forEach($scope.details, function (detail) {
$scope.header = detail.header;
$scope.intro = detail.id;
});
这是视图中的 html,看看我是如何暴露它的
<div ng-repeat="image in detail.images">
<img class="img-responsive presentation" ng-src="{{ image.path }}" />
<table class="like-table">
<tr>
<td>
<a ng-click="likeCount = likeCount + 1">
<img class="presentation like" ng-src="{{ like }}" />
</a>
</td>
<td>Like: </td>
<td>
<strong> {{ likeCount }}</strong>
</td>
<td>
<a ng-click="shareCount = shareCount + 1">
<img class="presentation like" ng-src="{{ share }}" />
</a>
</td>
<td>Share: </td>
<td>
<strong> {{ shareCount }}</strong>
</td>
</tr>
</table>
</div>
【问题讨论】:
-
如果您向我们展示了视图 HTML 代码的相关部分,这将非常有用,因此我们可以更好地了解您的问题以及您希望描述如何显示。我不清楚您是否遇到问题的数据绑定(即向视图传递数据),因为您提到图像确实显示。另外,您使用的是 Angular 1.x 还是 Angular2?
-
我已经添加了关键组件。我很确定此时是我的 json 对象的构造,而不是 html。我可能需要更改一些绑定方式 - 但还不确定。
标签: arrays angularjs json image object