控制器:
public async Task<ActionResult> LoadProductImage( long id, short width, short height )
{
var byteArray = await _streamAceVqbzService.Proxy.DocumentByteArray_GetDataBy_IdAsync( id, width, height );
return File( byteArray , "image/jpeg" );
}
Angular JS:
getProductImage: function (imageId, width, height)
{
var deferred = $q.defer();
$http.post('/Product/LoadProductImage', JSON.stringify({id:imageId,width:width,height:height})).success(deferred.resolve).error(deferred.reject);
return deferred.promise;
}
// Get product image.
$scope.loadProductImage = function (itemAttributes)
{
var imageId = 0;
$.each(itemAttributes, function (index, data)
{
if (data.AttributeId == 1000700 && data.DataXml != null)
{
imageId = data.DataXml;
return false;
}
});
productRepository.getProductImage(imageId, 200, 144).then(function (imageArrary)
{
$scope.productImage = imageArrary;
});
return $scope.productImage = imageArrary;
}
查看:
<img class="ui-corner-all img-responsive defaultImageSize" ng-src="data:image/jpeg;base64;{{loadProductImage(product.ItemAttributes)}}" />