2015-06-20 61 views
0

我用相機插件來拍照,我想與大家分享的科爾多瓦社會共享插件,照片,但我不知道怎麼...相機插件+科爾多瓦社會共享

的相機工作正常,並顯示我拍的照片

ionicApp.controller("functions", function($scope, $rootScope, $cordovaCamera) { 

$rootScope.takePicture = function() { 
    var options = { 
     quality : 75, 
     destinationType : Camera.DestinationType.DATA_URL, 
     sourceType : Camera.PictureSourceType.CAMERA, 
     allowEdit : true, 
     encodingType: Camera.EncodingType.JPEG, 
     targetWidth: 300, 
     targetHeight: 300, 
     popoverOptions: CameraPopoverOptions, 
     saveToPhotoAlbum: false 
    }; 

    $cordovaCamera.getPicture(options).then(function(imageData) { 
     var image = document.getElementById('myImage'); 
     $rootScope.imgURI = "data:image/jpeg;base64," + imageData; 
    }, function(err) { 
     // An error occured. Show a message to the user 
    }); 
} 

});

ionicApp.controller( 「共享」,功能($範圍,$ cordovaSocialSharing){

$scope.shareAnywhere = function() { 
    $cordovaSocialSharing.share("#DSTRY_CAM", "#DSTRY_CAM", "www/imagefile.png", "http://DSTRYCAM.COM"); 
} 

});

但我怎麼能把之前拍攝的照片在這個共享功能?我相信正在改變「www/imagefile.png」,但我不知道如何。

謝謝你,和遺憾,我的英文不好

+0

注入rootScope並更改您的www/imagefile:$ rootScope.imgURI – aorfevre

+0

請在下面查看我的答案@ user5028421。 – filipvkovic

回答

2

請參閱本GitHub的鏈接。

https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

此科爾多瓦插件是$ cordovaSocialSharing你實際上是用ngCordova使用反射。您已經使用$ cordovaCamera獲得了您的base64圖片網址。所以你現在可以使用$ cordovaSocialSharing的share()函數來分享你的圖片。

例如,

$cordovaSocialSharing 
    .share(null,"filename.jpg", $rootScope.imgURI, null) 
    .then(function(result) { 
     // success callback 
    }, function(err) { 
     // error callback 
    }); 

這將讓你通過在iOS和Android的開放內置份額對話分享您的照片(「filename.jpg」的文件名下)。很簡單。

編輯:您還需要在您的控制器中包含$ rootScope。

+0

對不起,但不起作用,當我把$ rootScope.imgURI,功能不起作用 – user5028421

+0

請不要忘記在你的「共享」控制器參數@ user5028421中添加$ rootScope引用。你有他們在你的「功能」控制器。 – filipvkovic

+0

OMG所有這一次是這個問題,哈哈非常感謝你! – user5028421

相關問題