title: how to read a binary data in angularjs
body: <p>I've written an api service which fetch a binary data from $http. The problem is I don't know how to used that data to display the image. PS: the binary data is actually an image. </p>
  
  <p>This is my service api</p>
  
  <pre><code>getAvatar: function() {
      return $http({
        method  : 'GET',
        url     : 'domain.com',
        headers : {'Content-Type' : 'application/json'}
      });
    }
  </code></pre>
  
  <p>My controller</p>
  
  <pre><code>//get avatar
  $scope.userAvatar = function() {
      Api.getAvatar()
      .then(function(result) {
          //success
          console.log(result.data); //this is the binary data
          $scope.avatarImage = result.data;
          }
  
      }, function(result) {
          //errors
      });
  
  };
  </code></pre>
  
  <p>At first I thought that result that the api will give me is a url but it turns out a binary. Do I have to convert it first? </p>