I think that I'm having scope problems that I'm not able to fix, here is an explanation of my problem.
I want to create my own directive "my-create-content" to insert an "img" HTML template in the element where the directive had been defined. Then, I've defined ng-show in "img" and a timeout that evaluates ng-show to false, but after timeout "img" element is no hidden. I'm not sur if it's a scope problem because ng-src="{{imageUrl}}" it's evaluated correctly.
Here's my code:
.directive('myCreateContent', [function() {
function link(scope, element, attrs) {
scope.showImg = false;
function updateImg(url){
scope.imageUrl = url;
scope.showImg = true;
}
if (scope.grid[0].image){
updateImg(scope.grid[0].imageUrl);
setTimeout(function(){
scope.showImg = false;
}, scope.grid[0].duration);
}
}
return {
scope: {
grid: '='
},
template: '<img ng-show="showImg" ng-src="{{imageUrl}}" class="grid">',
link: link
};
}]);
And the HTML:
<div my-create-content grid="grid" class="container">
$timeoutin place ofsetTimeout. - AlwaysALearner