詳情鏈接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/cordova-3-cordovap_w_picpathpicker/
這是能從手機裏選擇多張圖片的插件,是當時在做相機、上傳圖片相關的功能時在ngCordova官網看到的,下面簡單介紹一下它的用法:
1、首先需要有一個簡單的項目,然後在命令行輸入添加插件的命令:
cordova plugin add https://github.com/wymsee/cordova-p_w_picpathPicker.git
2、在HTML中的代碼如下,要調用相應的控制器裏的函數來使用插件,我來簡單的寫一下:
<div ng-repeat="item in allImg">
<img class="full-p_w_picpath img-responsive" ng-src="`item`.`img`"
/>
<div>
3、在JS中的代碼如下,這個代碼寫在相應的控制器裏並且依賴‘$cordovaImagePicker’,記得在app.js裏依賴‘ngCordova’,這是ngCordova官網的控制器裏面的代碼,:
var options = {
maximumImagesCount: 10, //需要顯示的圖片的數量
width: 800,
height: 800,
quality: 80
};
$scope.getImages = function(){
$cordovaImagePicker.getPictures(options)
.then(function (results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
}
}, function(error) {
// error getting photos
});
}
這樣子就可以多選照片了,但是這個插件選擇完照片後的數據不是Base64格式,沒辦法上傳到我們的服務器,因此後來就放棄這種方法了,以後可以再研究下