Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ionic.bundle.js类型错误:无法读取属性';添加';未定义的_Javascript_Android_Cordova_Ionic Framework_Ionic - Fatal编程技术网

Javascript ionic.bundle.js类型错误:无法读取属性';添加';未定义的

Javascript ionic.bundle.js类型错误:无法读取属性';添加';未定义的,javascript,android,cordova,ionic-framework,ionic,Javascript,Android,Cordova,Ionic Framework,Ionic,在运行安卓4.2.2的SM-G386F设备上使用cordova插件相机版本1.2.0插件拍照后,我出现以下错误 我的爱奥尼亚版本是1.1.0 任何帮助都将不胜感激,因为我不知道如何解决这个问题 提前非常感谢任何愿意帮忙的人:)我以前也遇到过同样的问题。然后我就这么做了。我得到了输出 1.捕获图像 首先使用命令添加相机插件 cordova plugin add org.apache.cordova.camera HTML <button ng-click="takePhoto()">

在运行安卓4.2.2的SM-G386F设备上使用cordova插件相机版本1.2.0插件拍照后,我出现以下错误

我的爱奥尼亚版本是1.1.0

任何帮助都将不胜感激,因为我不知道如何解决这个问题


提前非常感谢任何愿意帮忙的人:)

我以前也遇到过同样的问题。然后我就这么做了。我得到了输出

1.捕获图像

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

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>
2.拍摄后保存照片

如果你想将这张照片保存在你的存储器中。请同时添加文件插件

cordova plugin add org.apache.cordova.file
控制器

$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);
    }

};
$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
        });
    }
};

如果您有任何疑问,请告诉我。谢谢

谢谢慕新!我将尝试并将其发送给我的用户,以便他可以尝试。我会让你知道:)@Pierre:很高兴帮助你。如果你有任何疑问,请询问me@Pierre字体很高兴帮助你
$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
        });
    }
};