2015-11-13 93 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

相關問題