将localStorage值传递给服务angularjs

时间:2014-11-24 16:39:37

标签: javascript angularjs ionic-framework

我制作一个控制器来拍摄或设置照片,然后使用ngcordova插件上传。

是否可以转换为服务,因此每次调用ng-click =" takePhoto"?

这是我的控制者:

.controller('CameraCtrl', function ($scope, $cordovaCamera, $ionicLoading, $localstorage) {
    //$scope.data = { "ImageURI" :  "Select Image" };
    $scope.takePicture = function() {
      var options = {
        quality: 50,
        destinationType: Camera.DestinationType.FILE_URL,
        sourceType: Camera.PictureSourceType.CAMERA
      };
      $cordovaCamera.getPicture(options).then(
        function(imageData) {
            $scope.picData = imageData;
            $scope.ftLoad = true;
            $localstorage.set('fotoUp', imageData);
            $ionicLoading.show({template: 'Foto acquisita...', duration:500});
        },
        function(err){
            $ionicLoading.show({template: 'Errore di caricamento...', duration:500});
            })
      }
})

我自己尝试但是当我投入services.js时会返回此错误:

ReferenceError: Camera is not defined

0 个答案:

没有答案