0
I need, when clicking on the Thumb image, write the image clicked on the div . currentImage
Script
.directive('galeria',function() {
return {
templateUrl:'scripts/directives/galeria/galeria.html',
restrict: 'E',
scope:{
'pasta':'@',
'restrito':'@',
},
controller: function($scope,$http){
// INICIAR CAROUSEL DA HOME
$(".thumbsGaleria").owlCarousel({
autoPlay:true,
jsonPath: "api/galeria.php?id="+$scope.pasta,
jsonSuccess: customDataSucesso,
afterAction: afterFunction
})
function customDataSucesso(data){
var content = "";
for(var i in data){
var img = data[i];
content += '<img src="painel/modulos/galerias/pastas/'+$scope.pasta+'/'+img+'" ng-click="currentClick('+img+')" style="width:100%; padding-right:10px; max-height:415px">'
}
$(".thumbsGaleria").html(content);
}
// FIM CAROUSEL
function afterFunction(elem){
var current = this.currentItem;
var src = elem.find(".owl-item").eq(current).find("img").attr('src');
$(".currentImage").html("<img src='"+src+"' >");
}
$scope.currentClick = function(imgCurrent){
$(".currentImage").html("<img src='"+imgCurrent+"' >");
}
}
} });
HTML
<section class="section box" >
<div class="thumbsGaleria"></div>
<div class="currentImage">
</div>
But the NG-CLICK does not work, when clicking on the item, nothing happens. I tried to put an ONCLICK by clicking the console returns that the specified function does not exist.
What’s the matter?
– Wallace Maxters
Where is the ng-click?
– celsomtrindade
There in the customDataSubject(date) function in var content
– Wilson Lavrador
Yes, I hadn’t noticed.. If you 'Inspect' the element after the page has been loaded, ngClick appears in the element?
– celsomtrindade
yes, it appears. However, clicking does not execute the function.
– Wilson Lavrador
I think you’re not passing the correct destination within ngClick or you’re not propagating change. Check with Inspect which src is assigned to "currentImg" after clicking. If there is a change in src, check that it is at the correct destination
– celsomtrindade
The point is not that you are not running the function by clicking on the ng-click item ...
– Wilson Lavrador
@When you find a solution, put it as an answer and accept it. Do not put the answer as part of the question. See the [tour].
– Maniero