Search code examples
typescriptangularcordova-pluginsionic2

Setting up Ionic 2 Cordova Camera Plugin


 initializeApp(){
     this.platform.ready().then(() => {
       {
     document.addEventListener("deviceready", onDeviceReady, false);
      }

   function onDeviceReady() {
       console.log(navigator.camera);
       console.log("Cordova");
      }

 }

We are trying to run the onDeviceReady function and console.log will not print out


Solution

  •  initializeApp(){
         this.platform.ready().then(() => {
             console.log(navigator.camera);
             console.log("Cordova");
         }
     }
    

    Platform.ready() resolves when deviceready has fired, so listening for it again is unnecessary. In this case, listening for it after it has fired will cause that handler to never execute.