I have api which is return the image whether it is present in the database or not, I have to use that api with angularJs to display that image in my UI.
I have to pass userid and check corresponding to that userid whether the image of that user is present or not, if present that display that image otherwise display dummy image.
AngularJs Code for taking image from server
QAApp.controller('imgCtrl', function ($scope, $http) {
// id is userid.
$scope.image = function (id) {
var request = $http({
method: 'GET',
url: server + 'api/image/' + id,
});
request.success(function(data, status, headers, config) {
$scope.response = data;
console.log($scope.response);
});
}
});
HTML code:
<div class="artst-pic pull-left">
<img src=" " alt="" class="img-responsive" />
</div>
Please tell me how can I do this.