-4
通过点击链接显示照片显示阵列的最后一个图像。 控制器:AngularJS通过点击
app.controller('ExampleController', function(PhotoService, $scope) {
var vm = this;
vm.showImg = false;
vm.load = function(event) {
vm.showImg = !vm.showImg;
if ($scope.link)
return;
PhotoService.getPhoto(event.rid)
.then(function success(response) {
response.data.forEach(function (element, index) {
$scope.link = '/load/img/'+ response.data[index].filename;
});
});
};
})
.service("PhotoService", function($http, $q) {
this.getPhoto = function(rid) {
return $http.get('http://portal.com/device/record/' + rid);
};
});
查看:
<a href="" ng-click="ShowImg = !ShowImg;vm.load(event)">Show images</a>
<img ng-show="ShowImg" ng-src="// link //" alt="фото"/>
如何通过点击打开的图像上进行,而不是将其显示在数组中以下。