I'm working on an AngularJS service. The first is getting a product's info from an API:
getProductInfo: function(ean) {
var deferred = $q.defer();
api.get('products/' + ean, {})
.then(function(data) {
service.currentProduct = data;
deferred.resolve(data);
}, function() {
delete service.currentProduct;
deferred.reject('Invalid EAN: ' + ean);
});
return deferred.promise;
},
For the second I want to take the EAN from product's info and use that as the variable to be placed in an external image link:
getProductImg: function() {
var ean = ???
var url = "http://externalurl" + ean + "_01c";
return(url);
},
Ideally I would like to combine these so the external image is part of getProductInfo, is this possible?
Thanks, Shanna