title: How to download an image by clicking on button into our local using angularjs?
body: <p>Hi I am new to <code>angularjs</code> and I saw a lot of questions on stackoverflow regarding this, but was not able to find a good solution.</p>
  
  <pre><code>&lt;button ng-click="download()"&gt;download&lt;/button&gt;
  </code></pre>
  
  <p>My requirement is 
  (1) I don't want to use <code>&lt;a&gt;</code> tag</p>
  
  <p>(2) I don't want to use <code>&lt;download&gt;</code> attribute, because it should be supported in all browsers.</p>
  
  <p>When user clicks on download button the image should get downloaded to client's local machine.</p>
  
  <p>Assume the image is coming from some url</p>
  
  <pre><code>&lt;script&gt;
  angular.module('myApp', []);
  
  angular.module('myApp').controller('HomeCtrl', ['$scope', '$http', function($scope, $http) {
  
    $scope.download=function()
    {
        $http.get(url).success(function(data){
               // code to download image here
          }).error(function(err, status){})
    }
  
  }]);
  &lt;/script&gt;
  </code></pre>