cordovaCamera图像在html中没有绑定

时间:2016-05-17 08:11:21

标签: html angularjs ionic-framework cordova-plugins

所以,我正在使用cordovaCamera插件拍照,然后在我的html视图中显示该照片,但奇怪的是图像没有绑定到视图,我很困惑,因为我做错了。这是我的代码

$scope.takePhoto = function(index) {
    var options = {
      destinationType : Camera.DestinationType.FILE_URI,
      sourceType : Camera.PictureSourceType.CAMERA,
      allowEdit : false,
      encodingType: Camera.EncodingType.JPEG,
      popoverOptions: CameraPopoverOptions,
      correctOrientation: true
    };

   // 3
    $cordovaCamera.getPicture(options).then(function(imageData) {
   // 4
    var imagetype;
      onImageSuccess(imageData);

      function onImageSuccess(fileURI) {
        createFileEntry(fileURI);
      }

      function createFileEntry(fileURI) {
        window.resolveLocalFileSystemURL(fileURI, copyFile, fail);
      }

     // 5
      function copyFile(fileEntry) {
        var name = fileEntry.fullPath.substr(fileEntry.fullPath.lastIndexOf('/') + 1);
        var newName = (new Date()).getTime() + name;
        window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(fileSystem2) {
          fileEntry.copyTo(
            fileSystem2,
            newName,
            onCopySuccess,
            fail
          );
        }, fail);
      }

       // 6
      function onCopySuccess(entry) {
        $ionicModal.fromTemplateUrl('templates/profile_picture.html', {
          scope: $scope,
          animation: 'slide-in-up'
        }).then(function(modal) {
          $scope.modal = modal;
          $scope.modal.show();
          $scope.myCroppedImage = entry.nativeURL;
        });

        $scope.$on('$destroy', function() {
          $scope.modal.remove();
        });
      }

      function fail(error) {
      }
    }, function(err) {
    });
  };

profile_picture.html

<ion-view view-title="Profile Picture" ng-controller="appCtrl">
    <ion-nav-bar class="menu-background" nav-view-direction="none" nav-view-transition="" hide-nav-bar="false">
        <ion-nav-buttons side="left">
            <button class="button button-icon button-clear ion-android-arrow-back" menu-toggle="left" ng-click="cancelCropModal()"></button>
        </ion-nav-buttons>
        <ion-nav-buttons side="right">
            <div>
                <button class="button button-icon button-clear ion-android-done" ng-click="closeCropModal()"></button>
            </div>
        </ion-nav-buttons>
    </ion-nav-bar>
    <ion-content>
    <div class="cropArea">
      <img-crop image="myImage" result-image="myCroppedImage"></img-crop>
            <img id="croppedImage" ng-src="{{myCroppedImage}}" alt="" />
    </div>
    </ion-content>
</ion-view>

但是,一旦捕获了图像,它就不会绑定到视图并且页面为空。为什么它不会绑定,可能是什么原因?

非常感谢任何帮助

由于

0 个答案:

没有答案