javascript - Can't display an image using angularJS -


hi i'm still new angularjs , spring mvc, server working fine when test on own can see image in client side it's not working , i'm having error in console angular.js:3153 data:image/jpeg;base64,{} net::err_invalid_url please.

productcontroller.java

@requestmapping(value = "/getimg/{id}", method = requestmethod.get)     @responsebody     public void getimg(@pathvariable long id, httpservletresponse response) throws ioexception {         bytearrayoutputstream baos = new bytearrayoutputstream();         response.setheader("content-disposition", "inline; filename=productimg.png");         model model = modelrepo.findbyid(id);         model.geturlimg();         fileinputstream in = new fileinputstream(model.geturlimg());         byte[] buffer = new byte[1024];         int len;         while ((len = in.read(buffer)) != -1) {             response.getoutputstream().write(buffer, 0, len);         }          response.setcontenttype("image");      } 

myservice.js

getimg : function(id)                         {                             return $http                             .get(                                     'http://127.0.0.1:9001/prototypepos/rest/products/getimg/'+id,                                     {responsetype : 'arraybuffer'})                             .then(                                     function(response) {                                         return response.data;                                     },                                     function(errresponse) {                                         console                                                 .error('error while fetching clients');                                         return $q.reject(errresponse);                                     });                         }, 

mycontroller.js

$scope.getimg = function(id,$compileprovider) {     productservice.getimg(id).then(function(data) {         $scope.image=data; console.log($scope.image +"***************");        }, function(errresponse) {         console.error('error while fetching allpdts');     }); }; 

in html code:

<img ng-src="data:image/jpeg;base64,{{image}}"> 


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -