2015-11-13 100 views
0

“加”我有拍照使用科尔多瓦 - 插件相机版本上SM-G386F设备运行1.2.0插件后,下面的错误Android 4.2.2ionic.bundle.js类型错误:无法读取属性未定义

我离子的版本是1.1.0

TypeError: Cannot read property 'add' of undefined 
    at Object.jqLite.addClass (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:46098:56) 
    at Object.beforeStart (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:40117:17) 
    at triggerAnimationStart (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:39950:28) 
    at runNextTask (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:37511:5) 
    at nextTick (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:37495:7) 
    at scheduler (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:37466:5) 
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:39942:15 
    at forEach (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:9163:20) 
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:39923:9 
    at Scope. (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:24560:36) 

任何帮助将是非常赞赏,因为我不知道如何解决!

非常感谢事先向任何人愿意帮助:)

回答

0

我面临同样的问题before.Then我只是遵循了这一tutorial。我得到了输出

1.Capture image

首先添加相机插件使用命令

cordova plugin add org.apache.cordova.camera 

HTML

<button ng-click="takePhoto()">Capture</button> 
<li ng-repeat="i in myImage"> 
    <img ng-src="{{baseURL+i}}"> 
</li> 

控制器

$scope.takePhoto = function() { 
    navigator.camera.getPicture(onSuccess, onFail, { 
     quality: 75, 
     targetWidth: 320, 
     targetHeight: 320, 
     destinationType: 0, 
     saveToPhotoAlbum: true 
    }); 

    function onSuccess(imageData) { 
     $scope.imgURI = imageData; 
     $scope.myImage.push($scope.imgURI); 
     $scope.$apply(); 

    } 

    function onFail(message) { 
     alert('Failed because: ' + message); 
    } 

}; 

2.Save photo after capture

如果你想保存这张照片在你的storage.Please添加文件插件还,

cordova plugin add org.apache.cordova.file 

控制器

$scope.takePhoto = function() { 
    if (window.cordova) { 
     var options = { 
      quality: 100, 
      destinationType: Camera.DestinationType.FILE_URI, 
      sourceType: Camera.PictureSourceType.CAMERA, 
      encodingType: Camera.EncodingType.JPEG, 
      cameraDirection: 1, 
      saveToPhotoAlbum: true 
     }; 
     $cordovaCamera.getPicture(options).then(function(imagePath) { 
      $scope.imgURI = imagePath; 
      //Grab the file name of the photo in the temporary directory 
      var currentName = imagePath.replace(/^.*[\\\/]/, ''); 
      //Create a new name for the photo 
      var d = new Date(), 
       n = d.getTime(), 
       newFileName = n + ".jpg"; 
      //Move the file to permanent storage 
      $cordovaFile.moveFile(cordova.file.tempDirectory, currentName, cordova.file.dataDirectory, newFileName).then(function(success) { 
       //success.nativeURL will contain the path to the photo in permanent storage, do whatever you wish with it, e.g: 
       //createPhoto(success.nativeURL); 

      }, function(error) { 
       //an error occured 
      }); 

     }, function(error) { 
      //An error occured 
     }); 
    } 
}; 

如果您有任何doubt.Please让我know.Thanks

+0

谢谢穆赫辛!我来试试,并将其发送给我的用户,所以他可以尝试一下。我会让你知道:) – Pierre

+0

@皮埃尔:很高兴帮助你。如果你有任何疑问,请问我 – Muhsin

+0

它的工作原理!非常感谢:) – Pierre

相关问题