title: Open the barcode scanner when opening the app
body: <p>I'm trying to make my own barcode scanner app. It should open like Snapchat which basically just means that when i'm opening the app the barcode scanner should showup immediately and not through clicking a button.
  I'm using Cordova and Ionics and I'm currently using the barcode scanner plugin from Phonegap which actually works fine BUT i can't make it work through just opening the app. The screen will just be white. It's working when i'm using a button but in the other case not.</p>
  
  <p>I'm new to Cordova and JavaScript and it would help me a lot if some of you can help!</p>
  
  <p>Thanks a lot :)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &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;title&gt;&lt;/title&gt;
  
    &lt;link rel="manifest" href="manifest.json"&gt;
    &lt;link href="lib/ionic/css/ionic.css" rel="stylesheet"&gt;
    &lt;link href="css/style.css" rel="stylesheet"&gt;
  
    &lt;!-- ionic/angularjs js --&gt;
    &lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
  
    &lt;!-- cordova script (this will be a 404 during development) --&gt;
    &lt;script src="cordova.js"&gt;&lt;/script&gt;
  
    &lt;!-- your app's js --&gt;
    &lt;script src="js/app.js"&gt;&lt;/script&gt;
    &lt;script src="js/controllers.js"&gt;&lt;/script&gt;
    &lt;script src="js/services.js"&gt;&lt;/script&gt;
  
    &lt;script type="text/javascript"&gt;
      function scan() {
        console.log("clicked");
        cordova.plugins.barcodeScanner.scan(function(result) {
          //success callback
          alert(JSON.stringify(result));
  
        }, function(error) {
          //error callback
          alert(JSON.stringify(error));
  
        });
      }
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body ng-app="starter"&gt;
    &lt;div class="bar bar-header"&gt;
      &lt;button class="button icon ion-navicon"&gt;&lt;/button&gt;
      &lt;h1 class="title"&gt;Header Buttons&lt;/h1&gt;
      &lt;button class="button"&gt;Edit&lt;/button&gt;
    &lt;/div&gt;
    &lt;ion-content class="has-header"&gt;
      &lt;!--&lt;button class="button button-positive" onclick="scan()"&gt;Click here to scan&lt;/button&gt;--&gt;
      &lt;script type="text/javascript"&gt;
        scan();
      &lt;/script&gt;
    &lt;/ion-content&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>