In my controller, I call a service. This service makes a request to a PHP file that gives me a URL to an image.
The reason for this is the image resides inside a "Media Vault" meaning I need to generate a hashed URL like so in order to view it:
http://xxxx.vo.llnwd.net/o35/s/xxx/test/thumbs/slide1.jpg?e=1365006137&h=5852aeaf5beeeebff05a601801b61568
The URL above has already expired so you won't see anything from that specific link.
My image tag is like so:
<img id="thumbnail" class="glow" ng-src="{{currentThumb}}" width="200" height="150"/>
currentThumb in my controller is:
$scope.currentThumb = ImageService.getImage({
'type' : 'thumb',
'index' : $scope.currentIndex + 1,
'location' : $scope.location
});
and my service looks like this:
app.factory('ImageService', function($http)
{
var image = null;
return {
promise:null,
getImage: function($data)
{
this.promise = $http.post('resources/auth.php',$data, {timeout:20000}).success(function(response)
{
image = response;
log(response);
})
}
}
});
The current ImageService successfully returns a URL (at least it shows the url in the console) and when clicking the log result in the console, the image loads fine. Any reason why the image isn't updating?
thumbnail.src = ImageService.getImage({...});also with no luck. I gethttp://localhost/vjs/undefined 404 not foundgetImage()after you get your response. Or are you resolving your promise?return image;after I setimage = responseand still nothing. It's like$scope.currentThumb = ImageService.getImage({...});isn't actually setting anything. Must be a problem with my service?this.promisepart, are you calling the method to resolve that promise? Try just calling the$http.poston its own without setting it equal tothis.promise. Also include thereturn image;part.