title: Taking screenshot via button in ionic/cordova using screenshot plugin
body: <p>I want my ionic project to take a screenshot and store it in camera roll.
  currently the button is not able to take any screenshot. I am testing the app on an android device.
  I am using this plugin: <a href="https://github.com/gitawego/cordova-screenshot" rel="nofollow">https://github.com/gitawego/cordova-screenshot</a></p>
  
  <p>index.html</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"&gt;
      &lt;link href="lib/ionic/css/ionic.css" rel="stylesheet"&gt;
      &lt;link href="css/style.css" rel="stylesheet"&gt; 
      &lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
      &lt;script src="js/ng-cordova.min.js"&gt;&lt;/script&gt;
      &lt;script src="cordova.js"&gt;&lt;/script&gt;
      &lt;script src="js/app.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body ng-app="starter"&gt;
      &lt;ion-view&gt;
        &lt;ion-content&gt;
          &lt;button class="button" ng-click="$cordovaScreenshot.capture()"&gt;screenshot&lt;/button&gt;
        &lt;/ion-content&gt;
      &lt;/ion-view&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>angular.module('starter', ['ionic','ngCordova'])
  .service('$cordovaScreenshot', ['$q', function($q) {
      return {
          capture: function(filename, extension, quality) {
          filename = filename || 'pic';
              extension = extension || 'jpg';
              quality = quality || '100';
  
              var defer = $q.defer();
  
              navigator.screenshot.save(function(error, res) {
                  if (error) {
                      console.error(error);
                      defer.reject(error);
                  } else {
                      console.log('screenshot saved in: ', res.filePath);
                      defer.resolve(res.filePath);
                  }
              }, extension, quality, filename);
  
              return defer.promise;
          }
      };
  }]);
  </code></pre>